Persistent table NotFound tables error for individual Google Sheets tables in gspread for Python

I am using gspread to collect data from several hundred Google Sheets. I am parsing files stored in Google Drive in a local directory and getting URLs for all spreadsheets in a specified folder. Then I use the python shell to traverse the urls and the shell script to trigger the python shell to start when the connection fails.

One of the reasons for the crashes is the SpreadsheetNotFound error. I did a quick check about halfway through and found that 21/139 (~ 15%) of my tables always get this error (I skipped the table if not found five times). I went with iPython and manually tested them with open_by_url, open_by_key and open (with 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 by pasting it into the browser and the browser goes straight to the spreadsheet without issue. The second most annoying part is that it works great for ~ 85% of spreadsheets, but 85% is not going to cut it.

I'm not even sure if this is solvable. I'm just wondering if anyone else has such a problem with gspread.

Thanks for any feedback.

Edit 1: Hm, all tables created with an error were created before 2/2/15. Older sheets have been updated to the newest version of Drive - this could affect the API.

+3


source to share


1 answer


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 am assuming you are using oAuth2. This means you need to add the email address in the json certificate file to the table.



Using OAuth2 for Authorization

See point 7:

Go to Google Sheets and share the spreadsheet with the email you have. in json_key ['client_email']. Otherwise, you will get a SpreadsheetNotFound exception when you try to open it.

+2


source







All Articles