I\'m new to GAS and I struggle with the permission system.
I\'m a normal Google drive user and I started a spreadsheet and tried to add some code to it. My code is worki
onEdit()
, like all simple triggers, is bound by the following restrictions (see official documentation):
- The script must be bound to a Google Sheets, Slides, Docs, or Forms file, or else be an add-on that extends one of those applications.
- They do not run if a file is opened in read-only (view or comment) mode.
- Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.
- They cannot access services that require authorization. For example, a simple trigger cannot send an email because the Gmail service requires authorization, but a simple trigger can translate a phrase with the Language service, which is anonymous.
- They can modify the file they are bound to, but cannot access other files because that would require authorization.
- They may or may not be able to determine the identity of the current user, depending on a complex set of security restrictions.
- They cannot run for longer than 30 seconds.
- In certain circumstances, editor add-ons run their onOpen(e) and onEdit(e) simple triggers in a no-authorization mode that presents some additional complications. For more information, see the guide to the add-on authorization lifecycle.
- Simple triggers are subject to Apps Script trigger quota limits.
The ones highlighted in bold apply to your question.
Basically, it boils down to this - UrlFetchApp.fetch()
is a service that requires authorization, so you won't be able to execute it from your onEdit(e)
trigger, even if you have its associated scope set in your manifest file.