Skip to content

Instantly share code, notes, and snippets.

@Rub21
Created March 6, 2024 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rub21/5114176c382e443aef8ef45fa0a22f34 to your computer and use it in GitHub Desktop.
Save Rub21/5114176c382e443aef8ef45fa0a22f34 to your computer and use it in GitHub Desktop.
from requests_oauthlib import OAuth2Session
client_id = r'n6BbW1HCLeK5ImKkRsrVjYkn2sdaroPIGLASpdovvXY'
client_secret = r'Bx7fPt8jPPi0jN9sv6GBMULlvo_5crNUGul_XxgZ5I4'
redirect_uri = 'http://127.0.0.1:8111/oauth_authorization'
scope = ["read_prefs"]
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
authorization_url, state = oauth.authorization_url('https://staging.openhistoricalmap.org/oauth2/authorize')
print(f"Visit {authorization_url} and paste the code in")
code = input()
token = oauth.fetch_token('https://staging.openhistoricalmap.org/oauth2/token',
code=code,
client_secret=client_secret)
print(token)
# save the token in a file somewhere or something
prefs = oauth.request(method='GET',url='https://staging.openhistoricalmap.org/api/0.6/user/preferences')
print(prefs.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment