From a3bc23ae75b39fd54c99d4af3cc341024f60c53e Mon Sep 17 00:00:00 2001 From: Radhika Agrawal Date: Wed, 14 Jan 2026 15:14:52 -0800 Subject: [PATCH 1/3] fix: Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false for bound tokens Signed-off-by: Radhika Agrawal --- google/genai/_api_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/google/genai/_api_client.py b/google/genai/_api_client.py index 3028c72a2..c2272b65d 100644 --- a/google/genai/_api_client.py +++ b/google/genai/_api_client.py @@ -538,6 +538,10 @@ def __del__(self) -> None: class BaseApiClient: """Client for calling HTTP APIs sending and receiving JSON.""" + ## Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false + ## to disable bound token sharing. + os.setenv('GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES', 'false') + def __init__( self, vertexai: Optional[bool] = None, From 87827337b62558927230cc7cda94701ab919391e Mon Sep 17 00:00:00 2001 From: Radhika Agrawal Date: Wed, 14 Jan 2026 15:21:43 -0800 Subject: [PATCH 2/3] fix: fix the formatting Signed-off-by: Radhika Agrawal --- google/genai/_api_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google/genai/_api_client.py b/google/genai/_api_client.py index c2272b65d..c6ddaccf3 100644 --- a/google/genai/_api_client.py +++ b/google/genai/_api_client.py @@ -540,7 +540,9 @@ class BaseApiClient: ## Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false ## to disable bound token sharing. - os.setenv('GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES', 'false') + os.environ['GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES'] = ( + 'false' + ) def __init__( self, From 7df8da49bbd6cad3f8f59d2a9dad5e8716ef8089 Mon Sep 17 00:00:00 2001 From: Radhika Agrawal Date: Wed, 14 Jan 2026 15:26:36 -0800 Subject: [PATCH 3/3] chore: add the issue linked in comment Signed-off-by: Radhika Agrawal --- google/genai/_api_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google/genai/_api_client.py b/google/genai/_api_client.py index c6ddaccf3..8049181f7 100644 --- a/google/genai/_api_client.py +++ b/google/genai/_api_client.py @@ -539,7 +539,8 @@ class BaseApiClient: """Client for calling HTTP APIs sending and receiving JSON.""" ## Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false - ## to disable bound token sharing. + ## to disable bound token sharing. Tracking on + ## https://github.com/googleapis/python-genai/issues/1956 os.environ['GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES'] = ( 'false' )