Fix a bug in get_copilot_token.py

This commit is contained in:
johnd0e
2025-07-13 02:35:21 +02:00
parent 7383d21c8e
commit 62130a8899

View File

@@ -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: