Home > Back-end >  Google Apps Script dynamically update Authorization Scopes
Google Apps Script dynamically update Authorization Scopes

Time:03-25

I have deployed an Apps Script as WebApp which makes calls to the Google Drive API. The App can provide some basic functionality using only the scope https://www.googleapis.com/auth/drive.metadata.readonly. However, some users would like to have additional functionality which requires the https://www.googleapis.com/auth/drive.readonly scope. Is there a way to dynamically update the Authorization Scopes for this App when the user is explicitly requesting this?

Manifest File (appsscript.json):

{
  "timeZone": "Europe/Berlin",
  "dependencies": {
    "enabledAdvancedServices": []
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/drive.metadata.readonly"
  ],
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "webapp": {
    "executeAs": "USER_ACCESSING",
    "access": "DOMAIN"
  }
}

CodePudding user response:

Sadly, there is no way of doing this using Apps Script.

However, depending on the user's preference, you may redirect the user to execute another script/web app which does the task which requires the more permissive scope.

You can also request a feature on Google's Issue Tracker here.

  • Related