Skip to content

Commit 1ae0e16

Browse files
GWealecopybara-github
authored andcommitted
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 <gweale@google.com> PiperOrigin-RevId: 852944533
1 parent 30d3411 commit 1ae0e16

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

src/google/adk/auth/credential_manager.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,13 @@ async def get_auth_credential(
176176
async def _load_existing_credential(
177177
self, callback_context: CallbackContext
178178
) -> Optional[AuthCredential]:
179-
"""Load existing credential from credential service or cached exchanged credential."""
179+
"""Load existing credential from credential service."""
180180

181181
# Try loading from credential service first
182182
credential = await self._load_from_credential_service(callback_context)
183183
if credential:
184184
return credential
185185

186-
# Check if we have a cached exchanged credential
187-
if self._auth_config.exchanged_auth_credential:
188-
return self._auth_config.exchanged_auth_credential
189-
190186
return None
191187

192188
async def _load_from_credential_service(

tests/unittests/auth/test_credential_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async def test_load_auth_credentials_no_credential(self):
133133

134134
@pytest.mark.asyncio
135135
async def test_load_existing_credential_already_exchanged(self):
136-
"""Test _load_existing_credential when credential is already exchanged."""
136+
"""Test _load_existing_credential ignores shared config cache."""
137137
auth_config = Mock(spec=AuthConfig)
138138
mock_credential = Mock(spec=AuthCredential)
139139
auth_config.exchanged_auth_credential = mock_credential
@@ -145,7 +145,7 @@ async def test_load_existing_credential_already_exchanged(self):
145145

146146
result = await manager._load_existing_credential(callback_context)
147147

148-
assert result == mock_credential
148+
assert result is None
149149

150150
@pytest.mark.asyncio
151151
async def test_load_existing_credential_with_credential_service(self):

0 commit comments

Comments
 (0)