惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
N
Netflix TechBlog - Medium
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
IT之家
IT之家
博客园 - Franky
雷峰网
雷峰网
博客园 - 聂微东
腾讯CDC
M
MIT News - Artificial intelligence
B
Blog RSS Feed
博客园_首页
罗磊的独立博客
S
SegmentFault 最新的问题
I
InfoQ
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
D
Docker
宝玉的分享
宝玉的分享
B
Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: enforce Codex forced OAuth refresh (#80738) · opencl...
simplyclever · 2026-05-15 · via Recent Commits to openclaw:main

@@ -141,6 +141,14 @@ function hasOAuthCredentialChanged(

141141

);

142142

}

143143144+

function canReuseOAuthCredentialAfterRefreshFailure(params: {

145+

forceRefresh?: boolean;

146+

attempted: Pick<OAuthCredential, "access" | "refresh" | "expires">;

147+

candidate: OAuthCredential;

148+

}): boolean {

149+

return !params.forceRefresh || hasOAuthCredentialChanged(params.attempted, params.candidate);

150+

}

151+144152

async function loadFreshStoredOAuthCredential(params: {

145153

profileId: string;

146154

agentDir?: string;

@@ -324,6 +332,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

324332

provider: string;

325333

agentDir?: string;

326334

cfg?: OpenClawConfig;

335+

forceRefresh?: boolean;

327336

}): Promise<ResolvedOAuthAccess | null> {

328337

const ownerAgentDir = resolvePersistedAuthProfileOwnerAgentDir(params);

329338

const authPath = resolveAuthStorePath(ownerAgentDir);

@@ -340,7 +349,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

340349

}

341350

let credentialToRefresh = cred;

342351343-

if (hasUsableOAuthCredential(cred)) {

352+

if (!params.forceRefresh && hasUsableOAuthCredential(cred)) {

344353

return {

345354

apiKey: await adapter.buildApiKey(cred.provider, cred, {

346355

cfg: params.cfg,

@@ -358,6 +367,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

358367

mainCred?.type === "oauth" &&

359368

mainCred.provider === cred.provider &&

360369

hasUsableOAuthCredential(mainCred) &&

370+

!params.forceRefresh &&

361371

isSafeToAdoptMainStoreOAuthIdentity(cred, mainCred)

362372

) {

363373

store.profiles[params.profileId] = { ...mainCred };

@@ -419,7 +429,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

419429

saveAuthProfileStore(store, ownerAgentDir);

420430

}

421431

credentialToRefresh = externallyManaged;

422-

if (hasUsableOAuthCredential(externallyManaged)) {

432+

if (!params.forceRefresh && hasUsableOAuthCredential(externallyManaged)) {

423433

return {

424434

apiKey: await adapter.buildApiKey(externallyManaged.provider, externallyManaged, {

425435

cfg: params.cfg,

@@ -485,6 +495,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

485495

provider: string;

486496

agentDir?: string;

487497

cfg?: OpenClawConfig;

498+

forceRefresh?: boolean;

488499

}): Promise<ResolvedOAuthAccess | null> {

489500

const key = refreshQueueKey(params.provider, params.profileId);

490501

const prev = refreshQueues.get(key) ?? Promise.resolve();

@@ -510,6 +521,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

510521

credential: OAuthCredential;

511522

agentDir?: string;

512523

cfg?: OpenClawConfig;

524+

forceRefresh?: boolean;

513525

}): Promise<ResolvedOAuthAccess | null> {

514526

const adoptedCredential =

515527

adoptNewerMainOAuthCredential({

@@ -524,7 +536,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

524536

readBootstrapCredential: adapter.readBootstrapCredential,

525537

});

526538527-

if (hasUsableOAuthCredential(effectiveCredential)) {

539+

if (!params.forceRefresh && hasUsableOAuthCredential(effectiveCredential)) {

528540

return {

529541

apiKey: await adapter.buildApiKey(effectiveCredential.provider, effectiveCredential, {

530542

cfg: params.cfg,

@@ -540,12 +552,21 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

540552

provider: params.credential.provider,

541553

agentDir: params.agentDir,

542554

cfg: params.cfg,

555+

forceRefresh: params.forceRefresh,

543556

});

544557

return refreshed;

545558

} catch (error) {

546559

const refreshedStore = loadAuthProfileStoreWithoutExternalProfiles(params.agentDir);

547560

const refreshed = refreshedStore.profiles[params.profileId];

548-

if (refreshed?.type === "oauth" && hasUsableOAuthCredential(refreshed)) {

561+

if (

562+

refreshed?.type === "oauth" &&

563+

hasUsableOAuthCredential(refreshed) &&

564+

canReuseOAuthCredentialAfterRefreshFailure({

565+

forceRefresh: params.forceRefresh,

566+

attempted: effectiveCredential,

567+

candidate: refreshed,

568+

})

569+

) {

549570

return {

550571

apiKey: await adapter.buildApiKey(refreshed.provider, refreshed, {

551572

cfg: params.cfg,

@@ -564,7 +585,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

564585

profileId: params.profileId,

565586

agentDir: params.agentDir,

566587

provider: params.credential.provider,

567-

previous: params.credential,

588+

previous: effectiveCredential,

568589

requireChange: true,

569590

});

570591

if (recovered) {

@@ -582,6 +603,7 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

582603

provider: params.credential.provider,

583604

agentDir: params.agentDir,

584605

cfg: params.cfg,

606+

forceRefresh: params.forceRefresh,

585607

});

586608

if (retried) {

587609

return retried;

@@ -601,6 +623,11 @@ export function createOAuthManager(adapter: OAuthManagerAdapter) {

601623

mainCred?.type === "oauth" &&

602624

mainCred.provider === params.credential.provider &&

603625

hasUsableOAuthCredential(mainCred) &&

626+

canReuseOAuthCredentialAfterRefreshFailure({

627+

forceRefresh: params.forceRefresh,

628+

attempted: effectiveCredential,

629+

candidate: mainCred,

630+

}) &&

604631

isSafeToAdoptMainStoreOAuthIdentity(params.credential, mainCred)

605632

) {

606633

refreshedStore.profiles[params.profileId] = { ...mainCred };