Last active
April 1, 2022 08:55
-
-
Save kcranston/6edfebf177f82af6c6f6e1db92e9c722 to your computer and use it in GitHub Desktop.
GitHub Device Flow
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 | |
client_id = "Iv1.8df72ad9560c774c" | |
header = {"Content-Type": "application/json", "Accept": "application/json"} | |
# Step 1 | |
payload1 = {"client_id": client_id,} | |
r = requests.post( | |
'https://github.com/login/device/code',headers=header,json=payload1 | |
) | |
data = r.json() | |
device_code = data['device_code'] | |
uri = data['verification_uri'] | |
user_code = data['user_code'] | |
# Step 2 | |
print("To authorize this app, go to {} and enter the code {}".format(uri,user_code)) | |
input('Press any key to continue once you have input the code successfully') | |
# Step 3 | |
payload3 = { | |
"client_id": client_id, | |
"device_code": device_code, | |
"grant_type": "urn:ietf:params:oauth:grant-type:device_code", | |
} | |
r = requests.post( | |
"https://github.com/login/oauth/access_token", headers=header, json=payload3 | |
) | |
print(r.json()) |
https://git.521000.bestmunity/t/device-flow-authentication/139181/3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉https://www.facebook.com/suudamhuusanqusaialbreazet1995/
like 👉http://m.me/suudamhuusanqusaialbreazet1995
https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#incorrect-client-cred