Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Surface HTTPError exception on 429 #117

Merged
merged 1 commit into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions adal/authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def _perform_dynamic_instance_discovery(self):
{"operation": operation})
raise

if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
if not util.is_http_success(resp.status_code):
return_error_string = u"{} request returned http error: {}".format(operation,
resp.status_code)
Expand Down
2 changes: 2 additions & 0 deletions adal/mex.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def discover(self):
"%(operation)s request failed", {"operation": operation})
raise

if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
if not util.is_http_success(resp.status_code):
return_error_string = u"{} request returned http error: {}".format(operation, resp.status_code)
error_response = ""
Expand Down
6 changes: 6 additions & 0 deletions adal/oauth2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ def get_token(self, oauth_parameters):
if util.is_http_success(resp.status_code):
return self._handle_get_token_response(resp.text)
else:
if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
return_error_string = _ERROR_TEMPLATE.format(operation, resp.status_code)
error_response = ""
if resp.text:
Expand Down Expand Up @@ -305,6 +307,8 @@ def get_user_code_info(self, oauth_parameters):
if util.is_http_success(resp.status_code):
return self._handle_get_device_code_response(resp.text)
else:
if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
return_error_string = _ERROR_TEMPLATE.format(operation, resp.status_code)
error_response = ""
if resp.text:
Expand Down Expand Up @@ -334,6 +338,8 @@ def get_token_with_polling(self, oauth_parameters, refresh_internal, expires_in)
token_url.geturl(),
data=url_encoded_code_request, headers=post_options['headers'],
verify=self._call_context.get('verify_ssl', None))
if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError

util.log_return_correlation_id(self._log, operation, resp)

Expand Down
2 changes: 2 additions & 0 deletions adal/user_realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def discover(self):
verify=self._call_context.get('verify_ssl', None))
util.log_return_correlation_id(self._log, operation, resp)

if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
if not util.is_http_success(resp.status_code):
return_error_string = u"{} request returned http error: {}".format(operation,
resp.status_code)
Expand Down
2 changes: 2 additions & 0 deletions adal/wstrust_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def acquire_token(self, username, password):

util.log_return_correlation_id(self._log, operation, resp)

if resp.status_code == 429:
resp.raise_for_status() # Will raise requests.exceptions.HTTPError
if not util.is_http_success(resp.status_code):
return_error_string = u"{} request returned http error: {}".format(operation, resp.status_code)
error_response = ""
Expand Down