fix: change 'internal_failure' condition to also use `error' field (#387)
* fix: change `internal_failure` condition to also use `error' field
In some cases response doesn't contain `error_description` field. So the retry won't work. The solution is to look at both `error` and `error_description` fields.
diff --git a/tests/oauth2/test__client.py b/tests/oauth2/test__client.py
index c415a1f..9cf59eb 100644
--- a/tests/oauth2/test__client.py
+++ b/tests/oauth2/test__client.py
@@ -112,15 +112,21 @@
def test__token_endpoint_request_internal_failure_error():
request = make_request(
- {"error": "internal_failure", "error_description": "internal_failure"},
- status=http_client.BAD_REQUEST,
+ {"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"},
+ request, "http://example.com", {"error_description": "internal_failure"}
+ )
+
+ request = make_request(
+ {"error": "internal_failure"}, status=http_client.BAD_REQUEST
+ )
+
+ with pytest.raises(exceptions.RefreshError):
+ _client._token_endpoint_request(
+ request, "http://example.com", {"error": "internal_failure"}
)