asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
543 stars 154 forks source link

500 Error for sheets listing #94

Closed kostiag closed 9 years ago

kostiag commented 9 years ago

This is also posted on stackoverflow (http://stackoverflow.com/questions/31011790/google-sheets-api-500-error-for-sheets-listing) as I am pretty sure it is not library specific, but hoping someone ran into this and able to help.

I am hoping someone can help me figure out why I can't get the Google Sheets API to return a list of sheets for some users.

I am attempting to use the Google Sheets API to get a list of sheets available from a user's account after they have given authorization.

Things seems to be working for the most part, but I am getting 500 Error for a number of users who have tried to test the functionality. If User1 who experiences the failure shares all of his sheets with User2 who has not experienced the failure, User2 continues to work without experiencing any failure. I believe that rules out an issue with any particular sheet. (Unless of course a sheet that is "shared" with User2 is somehow different than a sheet that is actually in and owned by User1's account.)

I think the problem must be something with this particular user account or their settings, but I don't understand what it might be or how to work around this. The failure is always reproduceable for specific users for whom it fails, and success is always consistent for specific users for whom it does work. It may be important to note that the users with the failures are indeed able to successfully access from the Google Drive and Google Sheets web-interface every sheet in their account (whether owned by them or shared with them).

The requests that have received both failures and successes are being made in exactly the same format. However, the key length is the only real difference I noticed between the requests that succeeded and the requests that failed. In my limited sample set of tests, the successful requests seem to have the longer keys whereas the failed request have shorter keys. Here is an example of each with part of the key redacted:

FAILED https://spreadsheets.google.com/feeds/worksheets/t-4-L-cbXXXXXXXXXXm2lA/private/full

GOOD https://spreadsheets.google.com/feeds/worksheets/1n7rDwb5gwt1XXXXXXXXXXYzUz2_F4nEqMhaK4Odk/private/full

Also, I have tested this with both personal Google user accounts as well as with Google Apps user accounts. I have examples of both types that both work, and that fail.

Does anyone have any ideas how to trouble shoot this, or what else to try, or what other information may be helpful?

Thank you!

kostiag commented 9 years ago

This was caused by invalid sheet returned by getSpreadsheets when accessing getWorksheets on that spreadsheet that no longer exists exception is thrown due to 500 error.