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

REST API docs should recommend passing access token via header, not parameter #1080

Open
C-nit opened this issue Dec 2, 2024 · 0 comments
Open

Comments

@C-nit
Copy link

C-nit commented Dec 2, 2024

The REST API documentation suggests to pass the access token as a url parameter:
https://developers.zenodo.org/#quickstart-upload:~:text=deposit/depositions%27%2C-,params%3D%7B%27access_token%27%3A%20ACCESS_TOKEN%7D,-)%0Ar.

While this might be handy to have when one doesn't have access to developer environment (as one can issue authorized GET calls in a browser), I understand that secrets should generally not be passed via url query parameters.
The reasons are discussed here: https://blog.httpwatch.com/2009/02/20/how-secure-are-query-strings-over-https/

Given that it's already possible to pass the access token via headers, I would propose to change the documentation to recommend this way instead.
I hope this is the correct place to suggest this.


An example with python and the httpx package:

from httpx import Client

auth_header = {"Authorization": f'Bearer {os.environ["ZENODO_ACCESS_TOKEN"]}'}
client = Client(base_url="https://zenodo.org/api/", headers=auth_header)

r = client.get("deposit/depositions")
r.status_code
r.json()
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