Skip to content

Commit

Permalink
add a few missing raise_for_status()es
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Mar 29, 2021
1 parent 608bd7c commit 277133c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion oauth_dropins/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def get(self):
'redirect_uri': self.request.path_url,
}
resp = util.requests_post(GET_ACCESS_TOKEN_URL,
data=urllib.parse.urlencode(data)).text
data=urllib.parse.urlencode(data))
resp.raise_for_status()
resp = resp.text
logging.debug('Access token response: %s', resp)

resp = urllib.parse.parse_qs(resp)
Expand Down
1 change: 1 addition & 0 deletions oauth_dropins/mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def redirect_url(self, state=None, instance=None):
# actually a Mastodon instance)
try:
resp = util.requests_get(urljoin(instance, INSTANCE_API))
resp.raise_for_status()
except requests.RequestException as e:
logging.info('Error', stack_info=True)
resp = None
Expand Down
2 changes: 1 addition & 1 deletion oauth_dropins/webutil
5 changes: 3 additions & 2 deletions oauth_dropins/wordpress_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ def get(self):
'grant_type': 'authorization_code',
}
resp = util.requests_post(GET_ACCESS_TOKEN_URL, data=data)
resp.raise_for_status()
logging.debug('Access token response: %s', resp.text)

try:
resp = json_loads(resp.text)
resp = resp.json()
error = resp.get('error')
if error:
raise exc.HTTPBadRequest('Error: %s %s ' %
Expand All @@ -153,7 +154,7 @@ def get(self):
blog_domain = util.domain_from_link(resp['blog_url'])
access_token = resp['access_token']
except:
logging.error('Could not decode JSON', stack_info=True)
logging.error(f'Could not decode JSON: {resp.text}', stack_info=True)
raise

auth = WordPressAuth(id=blog_domain,
Expand Down

0 comments on commit 277133c

Please sign in to comment.