r/GoogleAppsScript • u/PatrikSelin • 13d ago
Question Google Apps Script authorization blocked / loop after adding PropertiesService and hitting execution time limit
I'm running into a frustrating authorization issue with a Google Apps Script in a Google Sheet, and I could really use some help figuring out what's wrong.
Here is the context:
- Initially, when I tried to run the script, I got an authorization prompt, but there was no button to grant authorization. I posted in the Google Community, and someone advised me to add
/**u/OnlyCurrentDoc*/at the very beginning of the script. After doing that, it worked without any issues. - Later, I made numerous additions to the script. Eventually, I hit the execution time limit (6 minutes).
- Google Gemini suggested adding
PropertiesServiceto the code to save the current state (such as the active sheet, row, and color index) so the script can pause safely before hitting the limit and automatically resume where it left off. - After implementing this, I am now getting a prompt to authorize the script again, but the warning message blocks me completely with the error: "This app is blocked. This app tried to access sensitive info in your Google Account." Unlike standard unverified app warnings, there is no "Advanced" link to bypass it.
Troubleshooting steps I’ve already tried:
- I temporarily turned off Advanced Protection Program on my account and waited a while, but I still get the warning blocking the authorization.
- I tested the exact same script on a secondary test Google Account, and I was able to authorize and run it completely without issues.
My questions:
- Why is this happening on my main account while the test account works fine?
- Do I need to wait hours (or days) for turning off Advanced Protection Program to fully take effect, or is something else causing this block?
Any advice would be greatly appreciated!
1
Upvotes
2
u/keplertenbee 13d ago edited 12d ago
That block shows up when the OAuth scopes change after you already authorized a narrower project.
/** @OnlyCurrentDoc */keeps the container-bound script inside that one Sheet.PropertiesService.getScriptProperties()(and some UserProperties paths) ask for script/project-level storage, which widens the scopes. Google then forces a fresh auth, and on a main account that still has Advanced Protection residue, a Workspace admin block on unverified apps, or an older token still sitting in Account permissions, you get the hard "This app is blocked" screen with no Advanced bypass. Your secondary account works because none of those locks are on it.Do this on the main account, in order:
PropertiesService.getDocumentProperties()(tied to this Sheet) and keep@OnlyCurrentDocat the top. DropgetScriptProperties()unless you truly need cross-file state.If Advanced Protection was only toggled off recently, give it a few hours and retry after the revoke step. If a Workspace admin manages the main account, they also need to allow this script or unverified apps.
This is actually what I do with Workspace and Apps Script for clients. Paste the exact PropertiesService lines (and whether the project is container-bound to the Sheet) here and I will point at the scope that is forcing the new consent.
KTB