I have created a standalone Google Apps Script (it does not belong to any document). The script get triggered automatically at some fixed intervals. This script
- creates a couple of folder (if they don't exist)
- creates a Google spreadsheet (if it doesn exist). Read said spreadsheet.
- update calendar events
I noticed that when I first run it, it asked for permissions to read, delete all Google Drive items, all spreadsheets and all calendar events
I work on tailoring the scopes required and at least Google Drive does not have those broad permissions. I am still unable to reduce the scope for Google spreadsheet (And also calendar). An expert @TheMaster made a post some years but is not exactly the same case.
I tried changing the scopes but the editor complained and requested that to use openById
I need to change the scopes back
CodePudding user response:
Manual authorization scopes for Sheets, Docs, Slides, and Forms
If you're building an add-on or other script that uses the Spreadsheet service, Document service, Slides service, or Forms service, you can force the authorization dialog to ask only for access to files in which the add-on or script is used, rather than all of a user's spreadsheets, documents, or forms. To do so, include the following JsDoc annotation in a file-level comment:
/** * @OnlyCurrentDoc */
Besides the above, look at each method reference documentation at the https://developers.google.com/apps-script/reference. At the bottom of the corresponding section you will find a list of the scopes that might be u sed for each method. Some methods have more than one scope, choose the one that better fits what you need.
Related
References
- https://developers.google.com/apps-script/guides/services/authorization
- https://developers.google.com/identity/protocols/oauth2/scopes
CodePudding user response:
Ok, I ended up how my solution was structured. Before Script lived outside the spreadsheet Now script lives inside the spreadsheet. I am now know doing scopes directly on the manifest and using onlycurrentdoc.