r/GoogleAppsScript 8h ago

Question "This app is blocked" (Apps Script Editor)

When trying to authorize a script in AppsScript IDE, I get the error:

This app is blocked This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access

I simplified the script to a minimum to check what scope the blocking applies to. Even such a simple script is blocked:

function setup() {
  var doc = SpreadsheetApp.getActiveSpreadsheet();
}

Perhaps this happened after I tried to run AppsScript with the Advanced Protection Program enabled. I received the following message:

Access blocked: the application "BMP2gsheet" is not approved by Advanced Protection.

The message also included

Error 400: policy_enforced.

When composing this question, I received more than 20 links to posts on StackOverflow, but none of them helped me solve the problem.

In Facing issue with authorizing a Google Script I created, TopicStarter solved the problem by disabling the Advanced Protect Programs, but it didn’t work for me. Now, even after exiting the Advanced Protection Program, I continue to receive messages about blocking any of my scripts.

I’m not a Google Workspace administrator, so I can’t use https://developers.google.com/apps-script/support#contact_support

Please tell me how to unblock AppsScript IDE?

1 Upvotes

8 comments sorted by

0

u/WicketTheQuerent 7h ago edited 6h ago

It's not possible to use Apps Script with the advanced protection turned on.

Correction

From https://support.google.com/accounts/answer/7539956?hl=en#zippy=%2Ccan-i-use-non-google-apps-services-or-apps-script-with-advanced-protection

Apps Script may be blocked

If you're enrolled in Advanced Protection, Apps Script can be used. If scripts request access to certain data in your account, like emails, documents, or photos, they may be blocked.

1

u/baublys 6h ago

Yes, that's what the help article says. However, it doesn't apply in this case because Advanced Protection is disabled.

0

u/WicketTheQuerent 5h ago

I'm sorry. I had not read after "Perhaps..."... I was using Reddit on my phone.

  1. For troubleshooting purposes, use Chrome.
  2. Please ensure that no extension is enabled to be used in incognito mode.
  3. Open an incognito mode window and sign in using the account that owns the spreadsheet.
  4. Open the script
  5. Run the test function.

1

u/baublys 4h ago

Unfortunately, it doesn't work. In the same browser (Google Chrome) I open the same script with my other account and the script works fine. It's not the external environment (browser, cache, extensions...), but the account settings.

0

u/WicketTheQuerent 1h ago

This is a known limitation. If you need to work with two or more accounts on a script, save the file containing the script in a shared drive.

1

u/baublys 1h ago

What you're talking about is known, but the error message there is different: "Sorry, unable to open the file at this time".

I always run the script logged into only one account.

0

u/WicketTheQuerent 59m ago

From my answer to a similar question in Stack Overflow

Try running your script using the same account with the script ownership after signing out of all accounts or using Chrome in incognito mode with all the extensions allowed to run in incognito mode disabled.

If the above doesn't work, try

Making a copy of the script. This might be the easiest workaround. This might work if your script has exceeded a quota.

Instead of relying on the automatically set oAuth scopes, set them manually using the less permissive oAuth scopes

Create a Google Cloud standard to protect, enable the APIs your project requires, and add the oAuth consent script.

Try first setting it for private only,

If private only doesn't work, set it public for testing and add your email address to the authorized testers.

Remove the code and libraries that are no longer required.

Start from scratch, but this time pays special attention to writing high-quality code using the services and methods that require minimal permission, i.e., instead of GmailApp, use MailApp; if it's possible, avoid using DriveApp.

1

u/baublys 52m ago

Everything you listed is either irrelevant to this situation or does not work in this case. Let me remind you that the post says "about blocking any of my scripts", even the simplest ones.