I'm having trouble authenticating my Apps Script project in a way that allows me to run functions using the built-in services like GmailApp, DriveApp, SpreadsheetApp, etc.
I followed the instructions in the run.md file in the project's docs folder, specifically:
Run a function that requires scopes
Many Apps Script functions require special OAuth Scopes (Gmail, Drive, etc.).
To run functions that use these scopes, you must add the scopes to your Apps Script manifest and clasp login again.
clasp open
File > Project Properties > Scopes
Add these scopes to your appsscript.json.
Log in again: clasp login --creds creds.json. This will add these scopes to your credentials.
Run: clasp run --user sendMail
Even after following the steps, I get the following error:
Exception: You do not have permission to call DriveApp.getFilesByName. Required permissions: (https://www.googleapis.com/auth/drive.readonly || https://www.googleapis.com/auth/drive) [ { function: 'MyFunction', lineNumber: 5 } ]
My appsscript.json File:
{
"timeZone": "America/Sao_Paulo",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "Drive",
"version": "v3",
"serviceId": "drive"
},
{
"userSymbol": "Sheets",
"version": "v4",
"serviceId": "sheets"
}
]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"executionApi": {
"access": "ANYONE"
},
"oauthScopes": [
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/spreadsheets"
]
}
Am I missing any additional steps to properly authenticate and gain access to these scopes? Is there a different way to authorize Apps Script functions when running them via clasp?
Any help would be greatly appreciated!
I'm having trouble authenticating my Apps Script project in a way that allows me to run functions using the built-in services like GmailApp, DriveApp, SpreadsheetApp, etc.
I followed the instructions in the run.md file in the project's docs folder, specifically:
Even after following the steps, I get the following error:
My appsscript.json File:
Am I missing any additional steps to properly authenticate and gain access to these scopes? Is there a different way to authorize Apps Script functions when running them via clasp?
Any help would be greatly appreciated!