Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Retry behavior #1113

Merged
merged 17 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
PR feedback.
  • Loading branch information
clundin25 committed Sep 22, 2022
commit 984580f114b22290bfb5820f5806218efff88a36
4 changes: 2 additions & 2 deletions google/oauth2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def id_token_jwt_grant(request, token_uri, assertion, can_retry=True):
id_token = response_data["id_token"]
except KeyError as caught_exc:
new_exc = exceptions.RefreshError(
"No ID token in response.", response_data, retryable=True
"No ID token in response.", response_data, retryable=False
)
six.raise_from(new_exc, caught_exc)

Expand Down Expand Up @@ -370,7 +370,7 @@ def _handle_refresh_grant_response(response_data, refresh_token):
access_token = response_data["access_token"]
except KeyError as caught_exc:
new_exc = exceptions.RefreshError(
"No access token in response.", response_data, retryable=True
"No access token in response.", response_data, retryable=False
)
six.raise_from(new_exc, caught_exc)

Expand Down
4 changes: 2 additions & 2 deletions google/oauth2/_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def jwt_grant(request, token_uri, assertion, can_retry=True):
access_token = response_data["access_token"]
except KeyError as caught_exc:
new_exc = exceptions.RefreshError(
"No access token in response.", response_data, retryable=True
"No access token in response.", response_data, retryable=False
)
six.raise_from(new_exc, caught_exc)

Expand Down Expand Up @@ -226,7 +226,7 @@ async def id_token_jwt_grant(request, token_uri, assertion, can_retry=True):
id_token = response_data["id_token"]
except KeyError as caught_exc:
new_exc = exceptions.RefreshError(
"No ID token in response.", response_data, retryable=True
"No ID token in response.", response_data, retryable=False
)
six.raise_from(new_exc, caught_exc)

Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/oauth2/test__client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def test_id_token_jwt_grant_no_access_token():

with pytest.raises(exceptions.RefreshError) as excinfo:
_client.id_token_jwt_grant(request, "http:https://example.com", "assertion_value")
assert excinfo.value.retryable
assert not excinfo.value.retryable


@mock.patch("google.auth._helpers.utcnow", return_value=datetime.datetime.min)
Expand Down Expand Up @@ -427,7 +427,7 @@ def test_refresh_grant_no_access_token():
_client.refresh_grant(
request, "http:https://example.com", "refresh_token", "client_id", "client_secret"
)
assert excinfo.value.retryable
assert not excinfo.value.retryable


@mock.patch("google.oauth2._client._parse_expiry", return_value=None)
Expand Down
6 changes: 3 additions & 3 deletions tests_async/oauth2/test__client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ async def test_jwt_grant_no_access_token():

with pytest.raises(exceptions.RefreshError) as excinfo:
await _client.jwt_grant(request, "http:https://example.com", "assertion_value")
assert excinfo.value.retryable
assert not excinfo.value.retryable


@pytest.mark.asyncio
Expand Down Expand Up @@ -283,7 +283,7 @@ async def test_id_token_jwt_grant_no_access_token():
await _client.id_token_jwt_grant(
request, "http:https://example.com", "assertion_value"
)
assert excinfo.value.retryable
assert not excinfo.value.retryable


@pytest.mark.asyncio
Expand Down Expand Up @@ -382,7 +382,7 @@ async def test_refresh_grant_no_access_token():
await _client.refresh_grant(
request, "http:https://example.com", "refresh_token", "client_id", "client_secret"
)
assert excinfo.value.retryable
assert not excinfo.value.retryable


@pytest.mark.asyncio
Expand Down