Last active
December 21, 2019 16:22
-
-
Save slint/576837c04f24924900c40a7d15ab2574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "..." | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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