Fix error when no token is returned by Github

This commit is contained in:
Joseph Schorr 2014-05-23 15:20:40 -04:00
parent a9a8105fbc
commit 81f235e5d6

View file

@ -35,7 +35,11 @@ def exchange_github_code_for_token(code, for_login=True):
get_access_token = client.post(app.config['GITHUB_TOKEN_URL'], get_access_token = client.post(app.config['GITHUB_TOKEN_URL'],
params=payload, headers=headers) params=payload, headers=headers)
token = get_access_token.json()['access_token'] json_data = get_access_token.json()
if not json_data:
return ''
token = json_data.get('access_token', '')
return token return token