google-sheetsgoogle-apps-scriptgoogle-cloud-platformpermissionsadd-on

Issues with Google App Script Add-on for Classroom Management in sheets - Script Errors on Different Accounts


I'm new to using Google Apps Script and I need some help. I'm working on a project to create a Google Sheet for managing Classroom that can be installed across our organization. My goal is for each admin to use it without needing to copy the code into their own Google Apps Script projects.

My code consists of two main scripts:

After several attempts, I successfully installed the script as an internal add-on within our organization using Google Cloud. The add-on works perfectly with my main account. However, when I try to use the add-on with another account, the spreadsheet template is created correctly, but the buttons linked to the script in the second code file generate the following error:

"An error occurred while reading data. Error code: PERMISSION_DENIED." // This is translated from Polish

I've read that such issues can occur when logged into multiple Google accounts simultaneously. To troubleshoot, I closed Chrome and logged into the problematic account using an Incognito window, but the same error persisted when using the buttons. I even tried different browsers, but the issue remained the same.

The necessary APIs for Classroom, Google Drive, Admin SDK, and Google Sheets are enabled in Google Cloud. When I pasted the code directly into Google Apps Script, the script worked fine. The problem only occurs when using the code as part of the add-on. It's puzzling why one part of the code (creating the template with buttons) works, but the script for managing queries throws an error.

I would appreciate it if someone could explain where I might be going wrong, what the underlying cause of the issue is, and what steps I should take to ensure everything works correctly. Thank you in advance for any assistance!


Solution

  • Replace the "buttons" by

    Among other options one to consider is to create a Workspace Add-on and use the Card Services to create the required buttons.

    The above is because it's known that a script might behave differently for the script owner than for add-on users. Considering this, when planning the User interface test your ideas early as they might impact the "backend" (server side scripting) work.

    Related