gspread “SpreadsheetNotFound” on certain workbooks

跟風遠走 提交于 2019-12-01 16:17:46

This sounds like you are hitting a limitation in gspread.

Even if you open a spreadsheet by key, gspread still first downloads a feed of all explicitely shared sheets using https://spreadsheets.google.com/feeds/spreadsheets/private/full and checks if the key you have provided is among them.

The problem is that this feed only lists 500 files. If your key is not among these 500, then you'll get SpreadsheetNotFound even if the spreadsheet is accessible.

I'd guess that the feed is ordered by most recently used, that explains why editing it makes it visible to gspread again.

The relevant issue is here.

My guess is that you may be hitting the Google Drive API limit of "Queries per 100 seconds per user", which is 1000 and cannot be changed to a higher value.

Solution 1:

You can try to apply for a higher quota by going to you project page:
1 - DASHBOARD
2 - QUOTAS
3 - Click on the pencil after "Queries per 100 seconds per user"
4 - Then click "Apply for higher quota"
5 - You'll end-up on https://support.google.com/code/contact/drive_quota, but if you follow steps above, the form will have the project and user details already filled.


Solution 2:

I had the same issue with just a couple of spreadsheets on my account, the problem was solved by:

1 - Opening the json key file (projectname-ca997255dada.json)
2 - Find the value of client_email , i.e.:

"client_email": "278348728734832-compute@developer.gserviceaccount.com",

3 - Share your sheet(s) with that email

Note: You can try to change just one spreadsheet that you cannot open and check if the above solve the problem.

I've run into this issue repeatedly. The only consistent fix I've found is to "re-share" the file with the api user. It already lists the api user as shared (since it's in the same shared folder as everything else), but after "re-sharing" I can connect with gspread no problem.

Based on this I believe it may actually be a permissions issue (Google failing to register the correct permission for the API user when accessing it through APIv3).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!