Created
May 6, 2024 20:23
-
-
Save rayne-hernandez/24a0263f205c2cebede32d998ad4916a to your computer and use it in GitHub Desktop.
OAuth Local Token generation
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
# Credentials you get from registering a new application | |
client_id = "" | |
client_secret = "" | |
# OAuth endpoints given in the GitHub API documentation | |
authorization_base_url = "" | |
token_url = "" | |
redirect_uri = "" | |
scope = [] | |
state = "random-string" | |
from requests_oauthlib import OAuth2Session | |
client = OAuth2Session(client_id=client_id, scope=scope, redirect_uri=redirect_uri, state=state) | |
authorization_url, state = client.authorization_url(authorization_base_url) | |
print(authorization_url, state) | |
authorization_response = input('Enter the full callback URL: ') | |
token = client.fetch_token( | |
token_url, | |
authorization_response=authorization_response, | |
client_secret=client_secret | |
) | |
print(token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment