diff --git a/packages/toolbox-adk/pyproject.toml b/packages/toolbox-adk/pyproject.toml index f648ea95a..794b76a2c 100644 --- a/packages/toolbox-adk/pyproject.toml +++ b/packages/toolbox-adk/pyproject.toml @@ -20,9 +20,9 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "toolbox-core==0.6.0", - "google-auth>=2.43.0,<3.0.0", + "google-auth>=2.47.0,<3.0.0", "google-auth-oauthlib>=1.2.0,<2.0.0", - "google-adk>=1.20.0,<3.0.0", + "google-adk>=1.26.0,<3.0.0", "typing-extensions>=4.0.0" ] diff --git a/packages/toolbox-adk/requirements.txt b/packages/toolbox-adk/requirements.txt index ef58745cd..91c59ae87 100644 --- a/packages/toolbox-adk/requirements.txt +++ b/packages/toolbox-adk/requirements.txt @@ -1,6 +1,6 @@ -e ../toolbox-core -google-adk==1.20.0 -google-auth==2.45.0 +google-adk==1.27.2 +google-auth==2.47.0 google-auth-oauthlib==1.2.1 typing-extensions==4.14.1 opentelemetry-exporter-otlp-proto-http==1.37.0 diff --git a/packages/toolbox-adk/src/toolbox_adk/tool.py b/packages/toolbox-adk/src/toolbox_adk/tool.py index 4e9e35279..db41f81b9 100644 --- a/packages/toolbox-adk/src/toolbox_adk/tool.py +++ b/packages/toolbox-adk/src/toolbox_adk/tool.py @@ -16,8 +16,6 @@ import logging from typing import Any, Awaitable, Callable, Dict, Mapping, Optional -import google.adk.auth.exchanger.oauth2_credential_exchanger as oauth2_credential_exchanger -import google.adk.auth.oauth2_credential_util as oauth2_credential_util import toolbox_core from fastapi.openapi.models import ( OAuth2, @@ -40,26 +38,6 @@ from .client import USER_TOKEN_CONTEXT_VAR from .credentials import CredentialConfig, CredentialType -# --- Monkey Patch ADK OAuth2 Exchange to Retain ID Tokens --- -# Google's ID Token is required by MCP Toolbox but ADK's `update_credential_with_tokens` natively drops the `id_token`. -# TODO(id_token): Remove this monkey patch once the PR https://github.com/google/adk-python/pull/4402 is merged. -_orig_update_cred = oauth2_credential_util.update_credential_with_tokens - - -def _patched_update_credential_with_tokens(auth_credential, tokens): - _orig_update_cred(auth_credential, tokens) - if tokens and "id_token" in tokens and auth_credential and auth_credential.oauth2: - setattr(auth_credential.oauth2, "id_token", tokens["id_token"]) - - -oauth2_credential_util.update_credential_with_tokens = ( - _patched_update_credential_with_tokens -) -oauth2_credential_exchanger.update_credential_with_tokens = ( - _patched_update_credential_with_tokens -) -# ------------------------------------------------------------- - class ToolboxTool(BaseTool): """ @@ -256,15 +234,9 @@ async def run_async( not hasattr(self._core_tool, "_auth_token_getters") or s not in self._core_tool._auth_token_getters ): - # TODO(id_token): Uncomment this line and remove the `getattr` fallback below once PR https://github.com/google/adk-python/pull/4402 is merged. - # self._core_tool = self._core_tool.add_auth_token_getter(s, lambda t=creds.oauth2.id_token or creds.oauth2.access_token: t) self._core_tool = self._core_tool.add_auth_token_getter( s, - lambda t=getattr( - creds.oauth2, - "id_token", - creds.oauth2.access_token, - ): t, + lambda t=creds.oauth2.id_token or creds.oauth2.access_token: t, ) # Once we use it from get_auth_response, save it to the auth service for future use try: