3
votes

I am using gspread to collect data from several hundred Google Sheets spreadsheets. I parse the files stored by Google Drive in a local directory and obtain the URLs for all the spreadsheets within a specified folder. Then I use a python wrapper to go through the URLs and a shell script wrapper to jump start the python wrapper when the connection glitches out.

One of the causes for the glitches is the SpreadsheetNotFound error. I did a quick check about halfway through and found that 21/139 (~15%) of my spreadsheets always get this error (I have it skip the spreadsheet if it's not found five times). I have gone in with iPython and manually tested these with open_by_url, open_by_key, and open (with the title), but they all return the same SpreadsheetNotFound error. The most frustrating part is being able to copy the URL directly from my error message, pasting it in the browser, and the browser going straight to the spreadsheet without a problem. The second most frustrating part is that it works beautifully for ~85% of the spreadsheets, but 85% is not exactly going to cut it.

I'm not even sure this is solvable. I'm just curious if anyone else out there has had this problem with gspread.

Thanks for any feedback.

Edit 1: Hm, the failing spreadsheets were all created prior to 2/2/15. The older sheets have been updated to the newest version of Drive - that may have had an effect on the API.

1

1 Answers

2
votes

From the Gspread docs:

ClientLogin is deprecated:
https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015.
Please use oAuth2 authorization instead:
http://gspread.readthedocs.org/en/latest/oauth2.html

So I assume you're using oAuth2. Which means you need to add the email address in that json cert file to the spreadsheet.

Using OAuth2 for Authorization

See point #7:

Go to Google Sheets and share your spreadsheet with an email you have in your json_key['client_email']. Otherwise you’ll get a SpreadsheetNotFound exception when trying to open it.