openclaw - 💡(How to fix) Fix Bug: gateway boot loads stale OAuth tokens on macOS; doesn't re-read keychain for `anthropic:claude-cli` profile (follow-up to #71026) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75790Fetched 2026-05-02 05:30:07
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
2
Timeline (top)
commented ×2closed ×1

Fix Action

Fix / Workaround

Workaround we patched today (this fork): wrote a chuck-mac-self-heal loop that re-reads keychain → auth-profiles.json on every boot. This belongs upstream in openclaw itself.

RAW_BUFFERClick to expand / collapse

This is a macOS-keychain analog of the recently-closed #71026 ("Auth token sync: claude-cli OAuth token not refreshed in auth-profiles.json"). The fix for #71026 covers Linux's ~/.claude/.credentials.json but the identical symptom still reproduces on macOS where Claude CLI stores the OAuth refresh-token in the macOS keychain (security framework) rather than a flat JSON file.

When anthropic:claude-cli (and similar keychain-backed OAuth profiles) refresh their token through claude CLI's auth flow, the new token lands in the keychain. But the gateway's auth-profiles.json cache holds the previous token until manually re-synced.

Reproduce:

  1. Configure anthropic:claude-cli OAuth profile.
  2. Force a token refresh via claude /login.
  3. Restart gateway. Observe: gateway uses the stale token from auth-profiles.json, not the fresh token in keychain. Provider calls fail with "401 invalid_credentials" until the user manually re-runs the keychain sync.

Workaround we patched today (this fork): wrote a chuck-mac-self-heal loop that re-reads keychain → auth-profiles.json on every boot. This belongs upstream in openclaw itself.

Proposed fix: on gateway boot, for any provider profile whose source is keychain (per the auth-profiles.json source field), re-read the keychain entry and update the in-memory cache. Specifically for the keychain-backed Anthropic OAuth path used by claude-cli, the keychain lookup is cheap (<10ms) so doing it on every boot has no measurable cost.

Code pointer: src/agents/auth/auth-profiles.ts (or wherever auth profiles hydrate during boot).

extent analysis

TL;DR

Update the gateway's auth-profiles.json cache by re-reading the keychain entry on boot for keychain-backed provider profiles.

Guidance

  • Identify keychain-backed provider profiles by checking the source field in auth-profiles.json.
  • On gateway boot, re-read the keychain entry for these profiles and update the in-memory cache.
  • Focus on the src/agents/auth/auth-profiles.ts file, where auth profiles are hydrated during boot, to implement the fix.
  • Consider the proposed chuck-mac-self-heal loop as a reference for the re-sync mechanism.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The fix should be applied upstream in openclaw itself, rather than relying on a patched fork. The keychain lookup is considered cheap, with a latency of less than 10ms, making it suitable for execution on every boot.

Recommendation

Apply the proposed fix by updating the gateway's auth-profiles.json cache on boot for keychain-backed provider profiles, as it addresses the root cause of the issue and has a negligible performance impact.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: gateway boot loads stale OAuth tokens on macOS; doesn't re-read keychain for `anthropic:claude-cli` profile (follow-up to #71026) [2 comments, 2 participants]