mirror of https://github.com/openclaw/openclaw.git
fix(auth): centralize oauth profile-id source openclaw#12692 thanks @mudrii
This commit is contained in:
parent
6a53a91ff3
commit
5e656a800c
|
|
@ -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",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -66,9 +66,10 @@ export async function writeOAuthCredentials(
|
|||
creds: OAuthCredentials,
|
||||
agentDir?: string,
|
||||
options?: WriteOAuthCredentialsOptions,
|
||||
): Promise<void> {
|
||||
): Promise<string> {
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue