From d4da1bb7330cdb87c1dcbe0b9023148357a6bd07 Mon Sep 17 00:00:00 2001 From: Kathy Wu Date: Wed, 14 Jan 2026 19:18:44 -0800 Subject: [PATCH] fix: Initialize self._auth_config inside BaseAuthenticatedTool So that we can access self._auth_config in McpTool for getting auth headers Co-authored-by: Kathy Wu PiperOrigin-RevId: 856451693 --- src/google/adk/tools/base_authenticated_tool.py | 1 + tests/unittests/tools/test_base_authenticated_tool.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/google/adk/tools/base_authenticated_tool.py b/src/google/adk/tools/base_authenticated_tool.py index 862d1cef..92e395d4 100644 --- a/src/google/adk/tools/base_authenticated_tool.py +++ b/src/google/adk/tools/base_authenticated_tool.py @@ -66,6 +66,7 @@ class BaseAuthenticatedTool(BaseTool): name=name, description=description, ) + self._auth_config = auth_config if auth_config and auth_config.auth_scheme: self._credentials_manager = CredentialManager(auth_config=auth_config) diff --git a/tests/unittests/tools/test_base_authenticated_tool.py b/tests/unittests/tools/test_base_authenticated_tool.py index 55454224..5f7bf53f 100644 --- a/tests/unittests/tools/test_base_authenticated_tool.py +++ b/tests/unittests/tools/test_base_authenticated_tool.py @@ -90,6 +90,7 @@ class TestBaseAuthenticatedTool: assert tool.description == "Test description" assert tool._credentials_manager is not None assert tool._response_for_auth_required == unauthenticated_response + assert tool._auth_config == auth_config def test_init_with_no_auth_config(self): """Test initialization without auth_config.""" @@ -99,6 +100,7 @@ class TestBaseAuthenticatedTool: assert tool.description == "Test authenticated tool" assert tool._credentials_manager is None assert tool._response_for_auth_required is None + assert tool._auth_config is None def test_init_with_empty_auth_scheme(self): """Test initialization with auth_config but no auth_scheme."""