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
This commit is contained in:
George Weale
2026-01-06 14:50:05 -08:00
committed by Copybara-Service
parent 30d3411d60
commit 1ae0e16b2c
2 changed files with 3 additions and 7 deletions
+1 -5
View File
@@ -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(
@@ -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):