Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Google Spreadsheets with a service account credentials?

I have created a server side application in PHP that's supposed to work with Google Spreadsheets.

I'm able to authenticate successfully with OAuth 2.0 authentication, but when requesting the list of the spreadsheets from Google, I only get the spreadsheets shared with the service account by the spreadsheet owner.

Is there a way that service account could retrieve all the spreadsheets owned by my main account not the service one, including those not explicitly shared with the service account?

Also I still want to keep the spreadsheets private so noone can access them without my permission, but I need the service account to have full access to both existing and new spreadsheets.

Any advice is appreciated.

like image 261
ZurabWeb Avatar asked Nov 21 '14 18:11

ZurabWeb


People also ask

Why am I denied access to my Google Sheets?

If a file won't open, a few things could be wrong: The file owner didn't give you permission to view the file. You're signed in to a different Google Account. Your access could be denied because someone removed your permission to view the file.


1 Answers

Here is a sample script that uses a service account to read the contents of a Google Spreadsheet's sheet. Have a look at the README for instructions to set it up:

https://github.com/juampynr/google-spreadsheet-reader

like image 93
Juampy NR Avatar answered Sep 21 '22 16:09

Juampy NR