Skip to content

Instantly share code, notes, and snippets.

@slint
Last active December 21, 2019 16:22
Show Gist options
  • Save slint/576837c04f24924900c40a7d15ab2574 to your computer and use it in GitHub Desktop.
Save slint/576837c04f24924900c40a7d15ab2574 to your computer and use it in GitHub Desktop.
import requests
res = requests.post(
'https://zenodo.org/oauth/token',
# This is a form submission, i.e. Content-Type: application/x-www-form-urlencoded
data={
'grant_type': 'authorization_code',
# the "code" parameter passed to the callback URL
'code': '<AUTHORIZATION_CODE>',
'client_id': '<CLIENT_ID>',
'client_secret': '<CLIENT_SECRET>',
# the callback URL
'redirect_uri': '<YOUR_REDIRECT_URL>',
}
)
import requests
res = requests.post(
'https://zenodo.org/oauth/token',
# This is a form submission, i.e. Content-Type: application/x-www-form-urlencoded
data={
'grant_type': 'authorization_code',
# the "code" parameter passed to the callback URL
'code': '<AUTHORIZATION_CODE>',
'client_id': '<CLIENT_ID>',
'client_secret': '<CLIENT_SECRET>',
# the callback URL
'redirect_uri': '<YOUR_REDIRECT_URL>',
}
)
res.json
# {
# "token_type": "Bearer",
# "user": {"email_verified": true, "id": "123456", "email": "[email protected]"},
# "access_token": "...",
# "scope": "user:email",
# "expires_in": 3600,
# "refresh_token": "..."
# }
curl -XPOST -H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code" \
# the "code" parameter passed to the callback URL
-d "code=<AUHTORIZATION_CODE>" \
-d "client_id=<CLIENT_ID>" \
-d "client_secret=<CLIENT_SECRET>" \
# the callback URL
-d "redirect_uri=<REDIRECT_URI>" \
"https://zenodo.org/oauth/token"
HTTP/1.1 200 OK
{
"token_type": "Bearer",
"user": {"email_verified": true, "id": "12345", "email": "[email protected]"},
"access_token": "...",
"scope": "user:email",
"expires_in": 3600,
"refresh_token": "..."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment