Add retry loop for fetching authentication token if any 'Internal Failure' occurs (#368)
* Add retry loop for fetching authentication token if any 'Internal failure' occurs
This is to prevent errors while client tries to connect with server and
fails with 'Internal Failure' because it was unable to fetch OAuth2
token.
* Add retry loop for fetching authentication token if any 'Internal failure' occurs
This is to prevent errors while client tries to connect with server and
fails with 'Internal Failure' because it was unable to fetch OAuth2
token.
diff --git a/tests/oauth2/test__client.py b/tests/oauth2/test__client.py
index 5a4a567..6fc4c3b 100644
--- a/tests/oauth2/test__client.py
+++ b/tests/oauth2/test__client.py
@@ -106,6 +106,18 @@
_client._token_endpoint_request(request, 'http://example.com', {})
+def test__token_endpoint_request_internal_failure_error():
+ request = make_request({'error': 'internal_failure',
+ 'error_description': 'internal_failure'},
+ status=http_client.BAD_REQUEST)
+
+ with pytest.raises(exceptions.RefreshError):
+ _client._token_endpoint_request(
+ request, 'http://example.com',
+ {'error': 'internal_failure',
+ 'error_description': 'internal_failure'})
+
+
def verify_request_params(request, params):
request_body = request.call_args[1]['body']
request_params = urllib.parse.parse_qs(request_body)