Skip to content

Commit

Permalink
fix: add useEmailAzp claim for id token iam flow (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 authored Apr 10, 2023
1 parent 976c7a6 commit 7a9c6f2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion google/oauth2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def call_iam_generate_id_token_endpoint(request, signer_email, audience, access_
Returns:
Tuple[str, datetime]: The ID token and expiration.
"""
body = {"audience": audience, "includeEmail": "true"}
body = {"audience": audience, "includeEmail": "true", "useEmailAzp": "true"}

response_data = _token_endpoint_request(
request,
Expand Down
5 changes: 2 additions & 3 deletions google/oauth2/service_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,9 @@ def _refresh_with_iam_endpoint(self, request):
request to IAM generateIdToken endpoint. The request body is:
{
"audience": self._target_audience,
"includeEmail": "true"
"includeEmail": "true",
"useEmailAzp": "true",
}
TODO: add "set_azp_to_email": "true" once it's ready from server side.
https://github.com/googleapis/google-auth-library-python/issues/1263
If the request is succesfully, it will return {"token":"the ID token"},
and we can extract the ID token and compute its expiry.
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
1 change: 1 addition & 0 deletions tests/oauth2/test__client.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def test_call_iam_generate_id_token_endpoint():
response_body = json.loads(request.call_args[1]["body"])
assert response_body["audience"] == "fake_audience"
assert response_body["includeEmail"] == "true"
assert response_body["useEmailAzp"] == "true"

# Check result
assert token == id_token
Expand Down

0 comments on commit 7a9c6f2

Please sign in to comment.