Created
March 6, 2024 00:29
-
-
Save Rub21/7bb178f8580401a20f04966e9adcae39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from requests_oauthlib import OAuth2Session | |
client_id = r'CV5dBzhOwDZkZeCj4xyosVOIJAkTuCZm-HlCK0P2Sfw' | |
client_secret = r'l3kMZgDojx8Kylh1_L0Eh9WD7KFORM4UEKZku66A7GY' | |
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://www.openstreetmap.org/oauth2/authorize') | |
print(f"Visit {authorization_url} and paste the code in") | |
code = input() | |
token = oauth.fetch_token('https://www.openstreetmap.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://www.openstreetmap.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