mirror of
https://gitea.com/PublicAffairs/openai-github-copilot.git
synced 2025-07-23 12:23:08 +02:00
Fix a bug in get_copilot_token.py
This commit is contained in:
@@ -36,16 +36,16 @@ def get_token():
|
||||
if resp.status != 200:
|
||||
raise Exception(f"Request failed with status {resp.status}: {resp.reason}")
|
||||
data = json.loads(resp.read().decode())
|
||||
if 'access_token' in resp:
|
||||
if 'access_token' in data:
|
||||
return data['access_token']
|
||||
elif data.get('error') == "authorization_pending":
|
||||
time.sleep(login_info['interval'])
|
||||
else:
|
||||
raise Exception(data['error_description'])
|
||||
raise Exception(data['error_description'] if 'error_description' in data else "Unexpected error")
|
||||
|
||||
|
||||
try:
|
||||
token = get_token()
|
||||
token = get_token(*sys.argv[1:2])
|
||||
except Exception as e:
|
||||
print(type(e).__name__, e)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user