From 5e656a800cc7883170de127cce6052d1d298a2f0 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Fri, 20 Feb 2026 15:56:03 +0530 Subject: [PATCH] fix(auth): centralize oauth profile-id source openclaw#12692 thanks @mudrii --- src/commands/auth-choice.apply.oauth.ts | 6 ++---- src/commands/auth-choice.apply.openai.ts | 6 ++---- src/commands/onboard-auth.credentials.ts | 8 +++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/commands/auth-choice.apply.oauth.ts b/src/commands/auth-choice.apply.oauth.ts index c5170d45533..0e9a5523ce0 100644 --- a/src/commands/auth-choice.apply.oauth.ts +++ b/src/commands/auth-choice.apply.oauth.ts @@ -68,11 +68,9 @@ export async function applyAuthChoiceOAuth( }); spin.stop("Chutes OAuth complete"); - await writeOAuthCredentials("chutes", creds, params.agentDir); - const chutesEmail = - typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"; + const profileId = await writeOAuthCredentials("chutes", creds, params.agentDir); nextConfig = applyAuthProfileConfig(nextConfig, { - profileId: `chutes:${chutesEmail}`, + profileId, provider: "chutes", mode: "oauth", }); diff --git a/src/commands/auth-choice.apply.openai.ts b/src/commands/auth-choice.apply.openai.ts index 0f62c8ed14b..2d1beaf041c 100644 --- a/src/commands/auth-choice.apply.openai.ts +++ b/src/commands/auth-choice.apply.openai.ts @@ -117,13 +117,11 @@ export async function applyAuthChoiceOpenAI( return { config: nextConfig, agentModelOverride }; } if (creds) { - await writeOAuthCredentials("openai-codex", creds, params.agentDir, { + const profileId = await writeOAuthCredentials("openai-codex", creds, params.agentDir, { syncSiblingAgents: true, }); - const codexEmail = - typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"; nextConfig = applyAuthProfileConfig(nextConfig, { - profileId: `openai-codex:${codexEmail}`, + profileId, provider: "openai-codex", mode: "oauth", }); diff --git a/src/commands/onboard-auth.credentials.ts b/src/commands/onboard-auth.credentials.ts index f0db9211cdb..03a0390363b 100644 --- a/src/commands/onboard-auth.credentials.ts +++ b/src/commands/onboard-auth.credentials.ts @@ -66,9 +66,10 @@ export async function writeOAuthCredentials( creds: OAuthCredentials, agentDir?: string, options?: WriteOAuthCredentialsOptions, -): Promise { +): Promise { const email = typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"; + const profileId = `${provider}:${email}`; const resolvedAgentDir = path.resolve(resolveAuthAgentDir(agentDir)); const targetAgentDirs = options?.syncSiblingAgents ? resolveSiblingAgentDirs(resolvedAgentDir) @@ -82,7 +83,7 @@ export async function writeOAuthCredentials( // Primary write must succeed — let it throw on failure. upsertAuthProfile({ - profileId: `${provider}:${email}`, + profileId, credential, agentDir: resolvedAgentDir, }); @@ -97,7 +98,7 @@ export async function writeOAuthCredentials( } try { upsertAuthProfile({ - profileId: `${provider}:${email}`, + profileId, credential, agentDir: targetAgentDir, }); @@ -106,6 +107,7 @@ export async function writeOAuthCredentials( } } } + return profileId; } export async function setAnthropicApiKey(key: string, agentDir?: string) {