Skip to content
Merged
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
9 changes: 7 additions & 2 deletions google/genai/_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ def join_url_path(base_url: str, path: str) -> str:

def load_auth(*, project: Union[str, None]) -> Tuple[Credentials, str]:
"""Loads google auth credentials and project id."""

## Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false
## 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'
)
credentials, loaded_project_id = google.auth.default( # type: ignore[no-untyped-call]
scopes=['https://www.googleapis.com/auth/cloud-platform'],
)
Expand Down Expand Up @@ -1946,5 +1953,3 @@ async def async_get_token_from_credentials(
raise RuntimeError('Could not resolve API token from the environment')

return credentials.token # type: ignore[no-any-return]