Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexboots opened this issue Aug 23, 2024 · 1 comment
Open

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

alexboots opened this issue Aug 23, 2024 · 1 comment

Comments

@alexboots
Copy link

alexboots commented Aug 23, 2024

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
Copy link
Author

I guess the most straightforward fix for this is passing sheet URL stripped of any params to .open_by_url since it doesn't need any of the params to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant