pygsheets icon indicating copy to clipboard operation
pygsheets copied to clipboard

resourcekey in URL causes client.open_by_url(sheet_url) to 404

Open alexboots opened this issue 6 months ago • 1 comments

Describe the bug Sometimes google sheet URL's have ?resourcekey=0-xyz-123 in them. Some do not. The ones that do fail with a 404 Url not found error.

The resource key is overviewed here: https://developers.google.com/drive/api/guides/resource-keys

A resource key helps protect your file from unintended access. Resource keys are an additional parameter that are passed so users can access certain files that have been shared using a link. Users who haven't viewed the file before must provide the resource key to gain access. Those who have recently viewed the file, or have direct access, don't need the resource key to access the file.

To Reproduce Steps to reproduce the behavior:

Call client.open_by_url(sheet_url) with an URL containing the ?resourcekey=0-xyz-123 key.

Sheet authorization failed: <HttpError 404 when requesting https://sheets.googleapis.com/v4/spreadsheets/0-xyz-123?includeGridData=false&fields=%2A&alt=json returned "Requested entity was not found.". Details: "Requested entity was not found.">

Remove the ?resourcekey=0-xyz-123 from the URL before passing it to client.open_by_url(sheet_url) causes the call to be made successfully (as long as proper access is set, of course).

System Information

  • OS: OSX local, deployed to unix env
  • pygsheets version : 2.0.6
  • pygsheets installed from (github or pypi): pypi

alexboots avatar Aug 23 '24 18:08 alexboots