'How to resolve "This app is blocked" error for shared Google Apps Script library?
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?
Solution 1:[1]
If the app is blocked for your account, there is an easy approach to allow it. Just keep in mind that you would need to be an admin in the domain in order to run these changes. Follow this guide on allowing apps and complete its steps. Feel free to leave a comment if you need more help.
Solution 2:[2]
I just wrote about this here: https://aimanfikri.com/2022/05/09/this-app-is-blocked-error-on-google-apps-script-solution/
In summary:
- Configure a 'standard project' on Google Cloud Platform.
- Set user access under 'Scopes'
- Add relevant user accounts (if you don't have an enterprise Google Workspace)
- Change your Apps Script project to the newly configured project using the new 'project number'.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jacques-Guzel Heron |
Solution 2 | Aiman |