Skip to content

fix: delete legacy auth.json after migration to prevent stale token overwrites#368

Merged
steipete merged 1 commit intoopenclaw:mainfrom
reeltimeapps:fix-oauth-stale-tokens
Jan 7, 2026
Merged

fix: delete legacy auth.json after migration to prevent stale token overwrites#368
steipete merged 1 commit intoopenclaw:mainfrom
reeltimeapps:fix-oauth-stale-tokens

Conversation

@reeltimeapps
Copy link
Copy Markdown
Contributor

Summary

Fixes #363 - Anthropic OAuth token spontaneously expires/fails to refresh

The root cause was that legacy auth.json files persisted after migration to auth-profiles.json. When the code loaded credentials from different agent directories, it would re-migrate stale tokens from these legacy files, overwriting fresh credentials.

This fix deletes the legacy auth.json file after successful migration to auth-profiles.json, preventing stale tokens from being re-migrated.

Changes

  • Delete legacy auth.json after successful migration in ensureAuthProfileStore()

Test plan

  • Existing tests pass (bun test src/agents/auth-profiles.test.ts)
  • Lint and build pass
  • Manually verified: after deleting legacy auth files, OAuth refresh works correctly

🤖 Generated with Claude Code

@steipete steipete self-assigned this Jan 7, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Matthew, thanks for digging and welcome to the Clawtributor Club!!! Are you on Discord yet?

@steipete steipete merged commit 0707b1e into openclaw:main Jan 7, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Merged locally + pushed to main.

  • Merge commit: 0707b1e (includes your 4f10279)
  • Follow-up hardening + regression test + docs/credits: 7176b114d419d16cd3ea5a0c178e99d7e20ae845

Thanks @reeltimeapps!,

dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic OAuth token spontaneously expires/fails to refresh

2 participants