From 81f235e5d60f7de1235db289bc5337dfcbaba618 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 23 May 2014 15:20:40 -0400 Subject: [PATCH] Fix error when no token is returned by Github --- endpoints/callbacks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/endpoints/callbacks.py b/endpoints/callbacks.py index 43aa2ac6b..4085798b0 100644 --- a/endpoints/callbacks.py +++ b/endpoints/callbacks.py @@ -35,7 +35,11 @@ def exchange_github_code_for_token(code, for_login=True): get_access_token = client.post(app.config['GITHUB_TOKEN_URL'], 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