Skip to content

fix: fall back to macOS Keychain when credentials file lacks OAuth token#90

Merged
neumie merged 1 commit intomainfrom
fix/claude-token-keychain-fallback
Mar 30, 2026
Merged

fix: fall back to macOS Keychain when credentials file lacks OAuth token#90
neumie merged 1 commit intomainfrom
fix/claude-token-keychain-fallback

Conversation

@neumie
Copy link
Copy Markdown
Contributor

@neumie neumie commented Mar 30, 2026

Summary

  • Fix Claude extension always showing "no access token found" when ~/.claude/.credentials.json exists but doesn't contain the claudeAiOauth key
  • The credentials file can contain other keys (e.g. mcpOAuth) causing the file read to succeed, which skipped the macOS Keychain fallback entirely

Changes

  • Refactored read_access_token() to check for the actual token in the file before considering it a valid source
  • If the file doesn't contain claudeAiOauth.accessToken, now correctly falls through to the macOS Keychain lookup

Test plan

  • On macOS with ~/.claude/.credentials.json containing only mcpOAuth, verify the Claude extension picks up the token from Keychain
  • On macOS with ~/.claude/.credentials.json containing claudeAiOauth, verify it still reads from the file
  • On macOS with no credentials file, verify Keychain fallback still works
  • Verify cargo check -p okena-ext-claude passes

The credentials file (~/.claude/.credentials.json) may exist but not
contain the claudeAiOauth key, causing read_access_token() to succeed
on file read but fail on token extraction—skipping the Keychain fallback
entirely. Now checks for the actual token before considering the file
source exhausted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@neumie neumie merged commit 401be9d into main Mar 30, 2026
8 checks passed
@neumie neumie deleted the fix/claude-token-keychain-fallback branch March 30, 2026 09:32
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