Skip to content

Commit cdd13c0

Browse files
fix: add useEmailAzp claim for id token iam flow (#1270)
1 parent d9b1806 commit cdd13c0

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/google-auth/google/oauth2/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def call_iam_generate_id_token_endpoint(request, signer_email, audience, access_
331331
Returns:
332332
Tuple[str, datetime]: The ID token and expiration.
333333
"""
334-
body = {"audience": audience, "includeEmail": "true"}
334+
body = {"audience": audience, "includeEmail": "true", "useEmailAzp": "true"}
335335

336336
response_data = _token_endpoint_request(
337337
request,

packages/google-auth/google/oauth2/service_account.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,9 @@ def _refresh_with_iam_endpoint(self, request):
743743
request to IAM generateIdToken endpoint. The request body is:
744744
{
745745
"audience": self._target_audience,
746-
"includeEmail": "true"
746+
"includeEmail": "true",
747+
"useEmailAzp": "true",
747748
}
748-
TODO: add "set_azp_to_email": "true" once it's ready from server side.
749-
https://github.com/googleapis/google-auth-library-python/issues/1263
750749
751750
If the request is succesfully, it will return {"token":"the ID token"},
752751
and we can extract the ID token and compute its expiry.
-1 Bytes
Binary file not shown.

packages/google-auth/tests/oauth2/test__client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def test_call_iam_generate_id_token_endpoint():
326326
response_body = json.loads(request.call_args[1]["body"])
327327
assert response_body["audience"] == "fake_audience"
328328
assert response_body["includeEmail"] == "true"
329+
assert response_body["useEmailAzp"] == "true"
329330

330331
# Check result
331332
assert token == id_token

0 commit comments

Comments
 (0)