chore(oauth): clear gmail legacy cache

This commit is contained in:
Peter Steinberger 2025-12-03 16:47:18 +00:00
parent f9a2e70c56
commit 5e1491d86c

View File

@ -255,6 +255,22 @@ export async function clearOAuthCaches(
const legacy = new DirectoryPersistence(legacyDir, logger);
await legacy.clear(scope);
}
// Known provider-specific legacy paths (gmail server writes to ~/.gmail-mcp/credentials.json).
const legacyFiles: string[] = [];
if (definition.name.toLowerCase() === 'gmail') {
legacyFiles.push(path.join(os.homedir(), '.gmail-mcp', 'credentials.json'));
}
await Promise.all(
legacyFiles.map(async (file) => {
try {
await fs.unlink(file);
logger?.info?.(`Cleared legacy OAuth cache file ${file}`);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
}
})
);
}
export async function readCachedAccessToken(definition: ServerDefinition, logger?: Logger): Promise<string | undefined> {