I'm trying to create a Google Apps Script (GAS) library that I can reuse across my Google Sheets spreadsheets. Following these instructions, here's what I've done so far:
Created a new project in Google Cloud Platform
Enabled Google Sheets API for project in step 1
Set up OAuth 2.0 authentication for project in step 1
- Credential type = User data
- Scopes = https://www.googleapis.com/auth/spreadsheets (I cannot use
spreadsheets.currentonly
because one method in this library requires the fullspreadsheets
scope) - OAuth Client ID = Web application
Configured OAuth consent screen
- Publishing status = Testing
- User type = External
- Test users = Gmail email I used to write the script
-
Set the Google Cloud Platform (GCP) Project to Standard by associating it with the Project Number from step 1
Updated
appsscript.json
to look like this:{ "timeZone": "America/Los_Angeles", "dependencies": { "enabledAdvancedServices": [ { "userSymbol": "Sheets", "version": "v4", "serviceId": "sheets" } ] }, "exceptionLogging": "STACKDRIVER", "runtimeVersion": "V8", "oauthScopes": [ "https://www.googleapis.com/auth/spreadsheets" ] }
Created a versioned deployment of my script following these instructions
Shared my GAS project as "Anyone on the internet with this link can view"
And here's the issue I'm facing:
Created a new Sheets using the same Google account that I used to create the GAS library
In the Scripts editor, I added my GAS library by entering the Script ID, then selected the HEAD version (it doesn't seem to matter -- all versions resulted in the same error)
In
Code.js
, wrote a test function that calls a function from my GAS libraryClicked the Run button to execute the test function; the following prompt appears:
Clicked "Review permissions" and selected the Google account I used to create the GAS library
ISSUE: This error page is displayed:
Now the strange part: if I repeat steps 1-5 above using a different Google account (i.e., not the same account I used to create the GAS library), then it works! I get the expected OAuth consent screen, and after granting permissions, I'm able to use my GAS library.
Has anyone figured out how to reuse a GAS library in a Sheets script that is under the same Google account as the one that was used to create the GAS library?