fix: allow re-auth with another google account (#6544)

This commit is contained in:
Arya Gummadi
2025-08-19 17:06:25 -07:00
committed by GitHub
parent 389102ec0e
commit 6505b0c8e1
2 changed files with 86 additions and 3 deletions

View File

@@ -391,13 +391,19 @@ function getCachedCredentialPath(): string {
return path.join(os.homedir(), GEMINI_DIR, CREDENTIAL_FILENAME);
}
export function clearOauthClientCache() {
oauthClientPromises.clear();
}
export async function clearCachedCredentialFile() {
try {
await fs.rm(getCachedCredentialPath(), { force: true });
// Clear the Google Account ID cache when credentials are cleared
await clearCachedGoogleAccount();
} catch (_) {
/* empty */
// Clear the in-memory OAuth client cache to force re-authentication
clearOauthClientCache();
} catch (e) {
console.error('Failed to clear cached credentials:', e);
}
}