Google Scripts Error "You do not have permission to call toast"? - google-apps-script

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.

Related

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

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.

Script does not have permission to perform that action after authorization granted CalendarApp

I've been executing a gscript for a couple years now, but just today I started seeing the following when I try to execute it:
The script does not have permission to perform that action. Required
permissions: (https://www.googleapis.com/auth/calendar ||
https://www.googleapis.com/auth/calendar.readonly ||
https://www.google.com/calendar/feeds)
I went ahead and deauthorized my script from my Account permissions page and re-ran the script to force re-auth, but I'm still seeing the error.
The line in question is simply trying to do:
CalendarApp.getDefaultCalendar()
Any idea on how to resolve this issue?
From what error you've encountered, it indicates that the script lacking the authorization needed to run. When a script is run in the Script Editor or from a custom menu item an authorization dialog is presented to the user. However, when a script is run from a trigger, embedded with a Google Sites page, or run as a service, the dialog cannot be presented and this error is shown.
If the script contains new unauthorized services, you must re-authorize the script. Here's a documentation on how to troubleshoot this type of error in Google Apps Script.
If a trigger continues to fire and cause this error, you can access your triggers by doing the following:
Select Edit > All your triggers in the Apps Script editor. The resulting dialog shows all active triggers running on your account.
Find the offending trigger in the list.
Click the clear icon next to the trigger name to remove it.
Click Save to record the deletion.
You can also remove problematic add-on triggers by uninstalling the add-on.

GAS onOpen() not running for copied spreadsheet

I have a spreadsheet with a script that includes onOpen() which successfully creates some custom menus. When I copied the spreadsheet (and the bound script of course), the onOpen() no longer runs. I tried a few things I found from other postings of the same problem:
Revoke the new spreadsheet's authorization - can't because it does not show up in my account as an authorized app.
Manually create a trigger for when the doc opens - I get an error "We're sorry, a server error occurred. Please wait a bit and try again."
Copied the script file itself and renamed it.
Renamed the enclosing script project.
Renamed the enclosing spreadsheet.
So, none of these has worked. Anything else I can try, or is there a known problem on Google's side?
Thanks!
I looked at the said issue tracker and found that the problem stemmed from this line of code:
DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId());
To make this work, I would suggest to enable the Drive API in Resources -> Advanced Google Services. It will also ask you to enable Drive API in your Google Dev console. Do this and let me know if it worked for you.

I keep receiving "Summary of failures for Google Apps Script: Script" error message even after I deleted all script for my google forms

I recently attempted to use script in GoogleForms to have all results emailed to my account and it didn't work and sent me error emails constantly. So I deleted all script, created new spreadsheets for all GoogleForms I'd created, and I am STILL receiving these error emails...
Looks like this:
**Your script, Script, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.
Summary:
Error Message Count
No item with the given ID could be found, or you do not have permission to access it. (line 20, file "Code") 24
Details:
Start Function Error Message Trigger End
5/7/13 9:45 PM sendFormByEmail No item with the given ID could be found, or you do not have permission to access it. (line 20, file "Code") time-based 5/7/13 9:45 PM**
I've checked in the script editor and such to see if there was anything, but there is nothing. I am really frustrated as this is a work account and I receive tons of these emails.
I'd appreciate any and all help!
Did you try "Resources / All your triggers" inside the editor? Your unwanted triggers might be visible there, but maybe not if they're deleted. If your scripts are still in your trash, you can try restoring them and then deleting the triggers. Beyond that, this is a long-known and still unaddressed issue. (Sorry, I'm not about to experiment with it myself - I don't want the headache if that goes badly.)
Issue 143: Spreadsheets with time triggered scripts should no longer trigger when spreadsheet is deleted
In the spreadsheet, just go to the Tools> Script Editor.
Then the new window should open and in that go to the Edit> All your Triggers.
Then click on the notifications link, and remove your email id.
Hope this helps someone.

User error: "You do not have authorization to perform that action." Google App Script

I have some GAS currently being run off of a spreadsheet. They will eventually move to a published service, however, the current issue needs to be resolved first.
I'm running into an issue where a script that I've written, and other users have used in the past are receiving the Subject error message.
A new script I can run (but others cannot) has been taken down to a single test function
function hello()
{ Browser.msg("Hello There") }
This still generates the "You do not have authorization to perform that action."
My older script has had no script changes and now users receive the same error.
I hadn't updated the Sharing settings on my script. Maybe that's what Jan was referring to...
Thanks Jan !