Show More
@@ -66,13 +66,13 b' def get_auth_token():' | |||||
66 | response = requests.post('https://api.github.com/authorizations', |
|
66 | response = requests.post('https://api.github.com/authorizations', | |
67 | auth=(user, pw), data=json.dumps(auth_request)) |
|
67 | auth=(user, pw), data=json.dumps(auth_request)) | |
68 | if response.status_code == 401 and \ |
|
68 | if response.status_code == 401 and \ | |
69 |
response.headers.get('X-GitHub-OTP' |
|
69 | 'required;' in response.headers.get('X-GitHub-OTP', ''): | |
70 |
print("Your login API re |
|
70 | print("Your login API requested a one time password", file=sys.stderr) | |
71 |
|
|
71 | otp = getpass.getpass("One Time Password: ", stream=sys.stderr) | |
72 | response = requests.post('https://api.github.com/authorizations', |
|
72 | response = requests.post('https://api.github.com/authorizations', | |
73 | auth=(user, pw), |
|
73 | auth=(user, pw), | |
74 | data=json.dumps(auth_request), |
|
74 | data=json.dumps(auth_request), | |
75 |
headers={'X-GitHub-OTP': |
|
75 | headers={'X-GitHub-OTP':otp}) | |
76 | response.raise_for_status() |
|
76 | response.raise_for_status() | |
77 | token = json.loads(response.text)['token'] |
|
77 | token = json.loads(response.text)['token'] | |
78 | keyring.set_password('github', fake_username, token) |
|
78 | keyring.set_password('github', fake_username, token) |
General Comments 0
You need to be logged in to leave comments.
Login now