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

fix: add useEmailAzp claim for id token iam flow #1270

Merged
merged 1 commit into from
Apr 10, 2023
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: 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