From 1ae0e16b2c1a3139b9c2b1c4a3e725833a6240be Mon Sep 17 00:00:00 2001 From: George Weale Date: Tue, 6 Jan 2026 14:49:30 -0800 Subject: [PATCH] fix: Remove fallback to cached exchanged credential in _load_existing_credential The _load_existing_credential method in CredentialManager will now only attempt to load credentials from the credential service and will no longer check the AuthConfig's exchanged_auth_credential cache. Close #3772 Co-authored-by: George Weale PiperOrigin-RevId: 852944533 --- src/google/adk/auth/credential_manager.py | 6 +----- tests/unittests/auth/test_credential_manager.py | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/google/adk/auth/credential_manager.py b/src/google/adk/auth/credential_manager.py index 2497c7b6..45a27f00 100644 --- a/src/google/adk/auth/credential_manager.py +++ b/src/google/adk/auth/credential_manager.py @@ -176,17 +176,13 @@ class CredentialManager: async def _load_existing_credential( self, callback_context: CallbackContext ) -> Optional[AuthCredential]: - """Load existing credential from credential service or cached exchanged credential.""" + """Load existing credential from credential service.""" # Try loading from credential service first credential = await self._load_from_credential_service(callback_context) if credential: return credential - # Check if we have a cached exchanged credential - if self._auth_config.exchanged_auth_credential: - return self._auth_config.exchanged_auth_credential - return None async def _load_from_credential_service( diff --git a/tests/unittests/auth/test_credential_manager.py b/tests/unittests/auth/test_credential_manager.py index ab021d1e..b7e01be6 100644 --- a/tests/unittests/auth/test_credential_manager.py +++ b/tests/unittests/auth/test_credential_manager.py @@ -133,7 +133,7 @@ class TestCredentialManager: @pytest.mark.asyncio async def test_load_existing_credential_already_exchanged(self): - """Test _load_existing_credential when credential is already exchanged.""" + """Test _load_existing_credential ignores shared config cache.""" auth_config = Mock(spec=AuthConfig) mock_credential = Mock(spec=AuthCredential) auth_config.exchanged_auth_credential = mock_credential @@ -145,7 +145,7 @@ class TestCredentialManager: result = await manager._load_existing_credential(callback_context) - assert result == mock_credential + assert result is None @pytest.mark.asyncio async def test_load_existing_credential_with_credential_service(self):