1

I have around 600 google sheets that are all very similar where I need to get values from one specific column. I've authenticated an app in the Google Developer console so I have access to one sheet. However to do so I had to give access to the Service Account from inside the sheet itself. That service account does not have access to the other 599 sheets and I would rather not go through and manually give it access to each sheet.

Does anyone have an idea for a better way to do this, either by authenticating the service account for all sheets or a better way of accessing hundreds of google sheets via python that won't mean I have to permission the account? My google account has access to all of the sheets if that helps.

Had a google but can't figure out how to do this! Any help appreciated.

purpletube
  • 21
  • 4

1 Answers1

0

You can use Permissions: create in Drive API to create a new permission to a specific file based on your preferred role.

Sample Request via API explorer:

FileId: Sheet file id where you want to add new permission

{
  "role": "writer",
  "type": "user",
  "emailAddress": "serviceaccount@email.com"
}

Please refer here for more detailed explanation regarding the Roles to be used.

Since your Google Account has access to all of the sheets, you just need to get the list of all your sheet files' id and loop each id to create a new permission for your service account using your Google Account.


Additional Reference:

Drive API Python Quickstart

Ron M
  • 5,791
  • 1
  • 4
  • 16