You tell the function which scopes are required in order for the tool to run effectively and it will verify that the user has accepted all of them before then running the rest of your code.
![]() |
| Screenshot of popup informing user they are missing some permission |
Instructions
- Copy the code into a new script file in the Editor, alongside your existing code. Either use your appsscript.json file (which you may need to 'show' via Project settings) or the Overview (Project Details) page in order to get a list of your Project OAuth Scopes. Copy the scopes into the REQUIRED_SCOPES section. Save the file.
- In the function 'mainFunction' either insert the main code that performs the necessary script for the tool that you built or call the function that performs the rest of your script, after the second line of code (the toast notification). Save the file.
- You need to make sure that the function 'mainFunction' is the first thing that is called when running the code going forwards. So if you use an onOpen Menu item for instance then point this to that function or if you have a button somewhere in your Google Sheet make sure its function call is updated.
- Done.
Caveat
This code is specifically for Google Sheet scripts. It relies on using the SpreadsheetApp UI in order to inform the user about missing permissions.
Download
Verify all permissions granted in a Google Sheet script download (please use 'Overview' > 'Make a copy' for your own version of the Apps Script file).

No comments:
Post a Comment