Skip to content

Fix Claude OAuth refresh handling#326

Merged
ratulsarna merged 13 commits intomainfrom
claude-keychain-refresh-fix
Feb 7, 2026
Merged

Fix Claude OAuth refresh handling#326
ratulsarna merged 13 commits intomainfrom
claude-keychain-refresh-fix

Conversation

@ratulsarna
Copy link
Collaborator

@ratulsarna ratulsarna commented Feb 7, 2026

Problem

CodexBar refreshed Claude OAuth using the refresh token read from the macOS Keychain item Claude Code-credentials. If the server rotates refresh tokens, CodexBar updated only its own cache, leaving Claude CLI holding an invalid refresh token and later hitting 401 / forced re-login.

Fix

  • Treat credentials loaded from Claude’s keychain / credentials file as Claude CLI-owned.
  • If expired, delegate refresh to claude (no direct token-endpoint refresh for Claude-owned creds).
  • After delegated refresh, re-read creds and retry OAuth once.
  • CodexBar-owned creds (if present) still refresh via the token endpoint.

Notes

  • On some systems, reading Claude Code-credentials can still trigger Keychain UI even after “Always Allow”, so OAuth-on-expiry may remain prompty.

Verification

  • swift test
  • pnpm check
  • ./Scripts/compile_and_run.sh

…sh-fix

# Conflicts:
#	Sources/CodexBarCore/KeychainAccessGate.swift
#	Tests/CodexBarTests/ClaudeOAuthCredentialsStoreTests.swift
#	Tests/CodexBarTests/ClaudeOAuthKeychainAccessGateTests.swift
#	Tests/CodexBarTests/KimiProviderTests.swift
@ratulsarna ratulsarna marked this pull request as ready for review February 7, 2026 13:36
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b254d0e0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ratulsarna
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa42272d2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ratulsarna
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ratulsarna ratulsarna merged commit 6a0c959 into main Feb 7, 2026
7 checks passed
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.

1 participant