Search code examples
google-apigoogle-oauthgoogle-api-php-client

Which GSheet API should I pick to request consent


We have an application that needs to append data to users' designated Gsheet. They should enter the sheet ID on our app, authorize it and then click export. Our app would then append a new row of data. We are not clear what is the best or the necessary Oath 2 scope that is appropriate for that.

  1. https://www.googleapis.com/auth/drive.file or
  2. https://www.googleapis.com/auth/spreadsheets

Any help is appreciated.


Solution

  • What you should do is check the documentation for what ever method you are trying to use. I am going to guess that you are using Method: spreadsheets.values.update

    This method requires one of the following scopes

    enter image description here

    Which one you pick is up to you. They will both work. Technically if your not going to be accessing any of the google drive api methods then there's probably no reason to use the drive scope.

    You can check the scopes#Sheets documentation for information on exactly what each scope gives you access to.

    enter image description here

    As you can see the sheets scope gives you access to all sheets a user has, while the drive.file scope will only give you access to files that where created by your app. Not just sheets.