Skip to content

Instantly share code, notes, and snippets.

@kcranston
Last active April 1, 2022 08:55
Show Gist options
  • Save kcranston/6edfebf177f82af6c6f6e1db92e9c722 to your computer and use it in GitHub Desktop.
Save kcranston/6edfebf177f82af6c6f6e1db92e9c722 to your computer and use it in GitHub Desktop.
GitHub Device Flow
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())
@Qusai1995albreazet
Copy link

{'error': 'incorrect_client_credentials', 'error_description': 'The client_id and/or client_secret passed are incorrect.', 'error_uri': 'https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#incorrect-client-credentials'}

[https://git.521000.bestmunity/t/device-flow-authentication/139181/3](http://m.me/suudamhuusanqusaialbreazet1995) @

@Qusai1995albreazet
Copy link

@Qusai1995albreazet
Copy link

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