I am unable to run any app script in my google account - even one created by me bound to a new document created by me. When I do, I get an "This App is Blocked" error. Note that this is different from the the "Sign in temporarily disabled for this app" failure mode mentioned elsewhere, and the solution for that problem has no effect on this one.
To test, I created a new spreadsheet while logged into my personal google account and put the value ONE
in cell A1
...
I then opened the Tools->Script
editor from the menu bar of this spreadsheet and entered the following trivial script...
I then click on the run icon from the script editor menu bar with the function "myFunction" selected from the pulldown.
I get an "authorization required" popup and so I click "Review Permissions"...
I then get a "Choose an account" popup and click on my account (the only logged in account, and the same account I was logged into when I created the sheet and the script)...
I then get an "App Blocked" popup. Checking the execution log shows that the script did not run.
What is causing this popup and how can I prevent this so I can run app scripts?
NOTE: I see many other questions describing more complicated versions of this issue but none have useful answers. I am hoping this ultra simple version of the issue will help narrow it down and get a resolution.
More unexpected behavior:
If I put the code into the onLoad()
function it works fine and never even asks me for authorization.
If I enter this code:
...and then quit out and reload the sheet, then I get this in the execution logs...
Again, this is with no authorization popups at all. The sheet loads without interruption and then the entry is in the execution logs. So this would seem to not be a case of not having the right permissions somewhere since code clearly can access the sheet.
Identical behavior under the legacy editor...
I can repeat these exact same steps on a different google account and it works fine, so this problem appears to be linked to my account. Many others on the internet have noted the same finding. Seems like there might be some hidden (probably unintional) setting attached to the account that gets switched somehow and then thereafter the account is not able to manually authorize scripts to run.
I check and this script is in the "Default" project as expected...
According to this page,
For most applications and scripts, you never need to see or adjust this default GCP project—Apps Script handles all the necessary interactions with the Google Cloud Platform automatically.
Since I have nothing to lose, tried creating a new project in the Google Cloud Platform console, and then tried assigning this script to that new project. Unfortunately when I tried, I got the normal "Authorization needed" popup which lead to this opdd page...
Clicking on the "Troubleshoot this problem" link takes me to this page...
...which seems to say that I do not have the permissions to troubleshoot problems on my own account.
This again seems to suggest there is something misconfigured about my account on google servers. :/
When a bound script is run as a web app or via the Apps Script API, these methods are not available. Bound scripts can customize Google Sheets, Docs, and Forms by adding custom menus and dialog boxes or sidebars. Keep in mind, however, that a script can only interact with the user interface for the current instance of an open file.
For personal accounts (rather than Google Workspace accounts) it looks like Apps Script blocks access to Calendar API and other sensitive information APIs. I was seeing the error message: "This app tried to access sensitive info in your Google Account.
"This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access." 1. You will probably need to set up a Google Cloud Platform (GCP) Project if you want to access Spreadsheet or Calendar scripts. You can link the GCP Project ID in the Project Settings panel of your Apps Script project.
A script is bound to a Google Sheets, Docs, Slides, or Forms file if it was created from that document rather than as a standalone script . The file a bound script is attached to is referred to as a "container".
Unfortunately there are no good answers there. Lots of people like me wake up one random morning to find that they can not run any new App Scripts in their account any more.
I've found a workaround that works great... but will make you very sad.
This issue does not affect code that runs automatically, so functions like onOpen()
and onEdit()
run just fine and have full access to the bound document. You heard that right- google blocks code that the user explicitly requests to run to protect their data, but code that runs silently and automatically anytime a sheet is opened or modified is free to run and access (and change!) whatever data it wants.
So to let the user run your code, you pick a cell inside the spreadsheet that either has a value that changes whenever you want your code to run, or you make a special cell called "Edit this cell to run the program".
Then you put your code inside the onEdit()
and (if desired) check to see to see if the special cell was updated. If so, then run your arbitrary code. It has full access to the spreadsheet and can read and update cells at will and can also write to the log.
Note that you must close the sheet and re-open it for the code to take effect.
Here is what my demo spreadsheet looks like...
...and here is the demo code...
function onEdit(e) {
var range = e.range;
const triggerCell = "B2";
if( e.range.getA1Notation() === triggerCell){
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
var rangeB1 =sheet.getRange("B1");
var rangeB2 =sheet.getRange("B2");
var date = Utilities.formatDate(new Date(), Intl.DateTimeFormat().resolvedOptions().timeZone, "HH:mm:ss");
rangeB2.setValue("Code ran at " + date );
Logger.log( date + ": B1=" + rangeB1.getValue() );
}
}
Here is a demo video...
https://youtu.be/ypuLaUWn1R8
I've said it before, I'll say it again - if you were thinking about using Google Cloud Services for anything then think again. This is crap built on top of crap that no one at google understands and it occasionally breaks suddenly and catastrophically, and there is no one who can even tell you what is going on much less how or when or if it is going to get fixed.
I ran into this for the first time today but my issue seems to be due to:
Using an account from the shared drive organization to create the script solved my issue.
This error
This app is blocked
seems to be a new error affecting certain Google accounts. This is reported to Google. Kindly star(add a star ★ to it on top left) to the following issues and comment to get Google developers to prioritize this issue:
https://issuetracker.google.com/issues/176138626
https://issuetracker.google.com/issues/181220763
#15 Creating a new GCP and linking it.
#12 Turning on Less Secure Apps
#10
This issue does NOT seem to be related to another issue 145162820:
"Sign in temporarily disabled for this app"
The error messages are different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With