Skip to content

Commit

Permalink
Merge pull request #37 from johngian/27-raise-status
Browse files Browse the repository at this point in the history
Raise error on OP 4xx/5xx responses
  • Loading branch information
johngian committed Nov 1, 2016
2 parents 98a1337 + 8c4f89a commit 8085886
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mozilla_django_oidc/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def authenticate(self, code=None, state=None):
response = requests.post(self.OIDC_OP_TOKEN_ENDPOINT,
json=token_payload,
verify=import_from_settings('VERIFY_SSL', True))
response.raise_for_status()

# Validate the token
token_response = response.json()
payload = self.verify_token(token_response.get('id_token'))
Expand All @@ -67,6 +69,7 @@ def authenticate(self, code=None, state=None):
})
user_response = requests.get('{url}?{query}'.format(url=self.OIDC_OP_USER_ENDPOINT,
query=query))
user_response.raise_for_status()
user_info = user_response.json()

try:
Expand Down

0 comments on commit 8085886

Please sign in to comment.