Can't run Google apps script, error 401: disabled_client - google-apps-script

I have a Google Sheets document that has a script attached to it and this AppScript includes a function that runs on a trigger every hour. The script fills in the sheet with importrange-formulas to get data from other sheets. It's been running fine for 6 months, but today I got an error.
The scheduled script has stopped running. When I try to manually run the function I get authorization request, and when I try to grant the script permission to run I get "Error 401: disabled_client".
I have similar scripts running in other Google Sheets document on similar trigger settings, and those keep running just fine. All the scripts are running on the same enterprise account.
Any ideas what can be going on here?
Grateful for any help to solve this.

Related

Random Exception - "Service timed out: Spreadsheets" in Google Apps Script

I have a Google Apps Script that works fine for most (>95%) of the time.
The script is bound to a Google Form and is set to be run on the 'On
Form Submit' event.
The script has a try-catch block.
This block catches an exception once in a while - Service timed out:
Spreadsheets.
There is no pattern to when this occurs. It is random.
Just to clarify. The script DOES NOT time out and IT DOES finish running as expected.
But, on random occasions, the script does not do it's job because of the "Service timed out: Spreadsheets" exception that is thrown when the script tries to write to a Google Spreadsheet.
Is there any way I can figure out what's the root cause of this? And is there anyway I can get some support for this issue?
I tried contacting Google Workspace support and they directed me here to SO to see if I can get some help.
You are most likely hitting one of the limitations of Apps Script. Perhaps you should time the function and try to optimize your code.

"Authorization is required to perform that Action" Error on a copy of existing code that works

I'm using Apps Script and the OAuth2 for Apps Script Library to connect to a couple Google advertising platforms. Basically, each account team has a Google sheet that automatically gets their campaign data every morning. I've got a couple of these sheets up and running already, but when I try to set up this most recent sheet I'm getting the "Authorization is required to perform that Action" at the very end of the OAuth process. I'm able to start the OAuth dialogue, select an account to authorize, but then I run into the error.
I authorized the script in the script editor before I ran it, and all of my OAuth credentials are correct. I've even deleted and re-created the scripts. The other sheets running the same scripts are still working fine.
What's going on here? I'd appreciate any ideas, I've set up a couple test sheets to see if I can puzzle it out, and now they're all returning the same error.
Update: Everything works properly when run from a different account, so it's looking like it's a problem with my account, specifically. Is there any way to manually check that an Apps Script project has been authorized correctly on a given account, aside from the prompt when the script is first created?
I ended up fixing it by explicitly setting the Authorization Scopes in the manifest. In case anyone finds this question later, here's the links to the relevant Apps Script guides:
Authorization Scopes:
https://developers.google.com/apps-script/concepts/scopes
List of OAuth 2.0 Scopes:
https://developers.google.com/identity/protocols/googlescopes

Google Scripts Error "You do not have permission to call toast"?

My coworkers started complaining today about problems they were having on a scheduling sheet that I automate with Google Scripts. I have not touched the code for this Spreadsheet for some time and was surprised to see the Stackdriver Logs full of errors:
You do not have permission to call toast at createJobFolder(Job_Files:112) at evaluateJobCode(Job_Code:29) at check(Triggers:14)
Did Google change anything about the permissions for .toast()? There was no new permission requests and I could not trigger one. Please advise.
Here is a quick way I have found to reproduce the error:
Paste the following code into the Script Editor:
function myFunction() {
SpreadsheetApp.getActive().toast('hello')
}
Run it to ok the permissions
Assign an edit event to it
Share it with another account and make an edit to reproduce the error.

All my news Google spreadsheets can't run a complex script

I've create a spreadsheet with a script for copy some other spreadsheet with a script inside, this worked fine for a moment.
But for several days all my scripts, on all news spreadsheets copied, they doesn't worked and they blocked when a complex line come (For example : DriveApp.getFileById(id))
(I say complex for script when onEdit, onOpen or other function can't run the line)
After somes researchs and reflexions, I think the problem come from the settings of my domain (G Suit), because when I use a new spreadsheet's script on an other account, they doesn't work, but if I use my old spreadsheet's scripts, they does work fine. I'm not sure.
The error messages I receive (it's when the script is out of time) are :
- An error has occurred on the server. We apologize and invite you to try
again later.
- Exceeded authorized execution time
I've tried to create a new spreadsheet and rewrite the script manually but I got the same error.
I'm not sure if it's only my domain, probably Google got some error too (But after 5 days it's strange).
Please, someone can help me, for say me if it's a problem with google, my domain or any other way.
(Sorry for my bad english)
Thanks in advance
Check the answer I've provided here.
You'll just have to enable Drive API for the project and from the Google Dev console.

414 Error for creating trigger for google app scripts

I have some exisiting google app scripts in a spreadsheet of my google drive.
Tried to create a time driven trigger under Script Editor -> Resources to automate the execution of a script. Encountered error: 414. That’s an error.
The requested URL /... is too large to process. That’s all we know.
Read through some of the existing similar issues/solution. Nothing specific to time driven triggers found.
Anyone has a workaround ?
Have you tried running the script without the trigger? I find most times I get that error it's because I'm trying to add a trigger to a script that I haven't yet run and authorised first. Good luck!