Skip to content

Commit

Permalink
medium bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Aug 15, 2016
1 parent af5d836 commit 6c45bd9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions oauth_dropins/medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ def get(self):
# handle errors
error = self.request.get('error')
if error:
error_description = urllib.unquote_plus(
self.request.get('error_description', ''))
if error == 'access_denied':
logging.info('User declined: %s', error_description)
logging.info('User declined')
self.finish(None, state=self.request.get('state'))
return
else:
Expand All @@ -149,12 +147,17 @@ def get(self):

try:
resp = json.loads(resp)
access_token = resp['access_token']
# TODO: handle refresh token
except:
logging.exception('Could not decode JSON')
raise

errors = resp.get('errors') or resp.get('error')
if errors:
logging.info('Errors: %s', errors)
raise exc.HTTPBadRequest(errors[0].get('message'))

# TODO: handle refresh token
access_token = resp['access_token']
user_json = MediumAuth(access_token_str=access_token).get(API_USER_URL).text
id = json.loads(user_json)['data']['id']
auth = MediumAuth(id=id, access_token_str=access_token, user_json=user_json)
Expand Down

0 comments on commit 6c45bd9

Please sign in to comment.