Fix oauth credential caching. (#2709)

This commit is contained in:
Tommaso Sciortino
2025-06-30 08:47:01 -07:00
committed by GitHub
parent f3849627fc
commit 5c4c833ddd
5 changed files with 23 additions and 25 deletions

View File

@@ -58,6 +58,9 @@ export async function getOauthClient(): Promise<OAuth2Client> {
clientId: OAUTH_CLIENT_ID,
clientSecret: OAUTH_CLIENT_SECRET,
});
client.on('tokens', async (tokens: Credentials) => {
await cacheCredentials(tokens);
});
if (await loadCachedCredentials(client)) {
// Found valid cached credentials.
@@ -130,8 +133,6 @@ async function authWithWeb(client: OAuth2Client): Promise<OauthWebLogin> {
redirect_uri: redirectUri,
});
client.setCredentials(tokens);
await cacheCredentials(client.credentials);
// Retrieve and cache Google Account ID during authentication
try {
const googleAccountId = await getGoogleAccountId(client);