Bug: claude setup-token prints token but doesn't save to keychain (macOS)

Resolved 💬 3 comments Opened Jan 19, 2026 by kat3samsin Closed Feb 27, 2026

claude setup-token prints token but doesn't save to keychain (macOS)

Description

When running claude setup-token in iTerm2 (macOS 15.2), the OAuth flow completes successfully and the token is printed to stdout, but it's not saved to keychain or ~/.claude/.credentials.json.

Steps to Reproduce

  1. Open iTerm2 (or Terminal.app)
  2. Run: claude setup-token
  3. Complete OAuth flow in browser
  4. Token is printed: sk-ant-oat01-...
  5. Exit terminal

Expected Behavior

  • Token saved to keychain under "Claude Code-credentials"
  • OR token saved to ~/.claude/.credentials.json
  • Can run claude commands in new sessions without re-authenticating

Actual Behavior

  • Token printed to stdout only
  • No keychain entry created
  • No ~/.claude/.credentials.json file created
  • Must manually save token and export as CLAUDE_CODE_OAUTH_TOKEN

Verification

# Check keychain
security find-generic-password -s "Claude Code-credentials" 2>&1
# Returns: "could not be found in the keychain"

# Check credentials file
ls -la ~/.claude/.credentials.json
# Returns: "No such file or directory"

Environment

  • Claude Code version: 2.1.12
  • OS: macOS 15.2 (Darwin 25.2.0)
  • Terminal: iTerm2 (build 3.5.10)
  • Node: v22.14.0
  • Installation: via npm/nvm

Related Issues

  • #9403 - macOS Keychain issue
  • #5244 - OAuth token not persisted
  • #9371 - Auth Token: none despite successful login

Workaround

Manually create the credentials file:

mkdir -p ~/.claude
cat > ~/.claude/.credentials.json << 'CRED'
{
  "claudeAiOauth": {
    "accessToken": "YOUR_TOKEN_HERE",
    "refreshToken": "",
    "expiresAt": 1800000000000
  }
}
CRED
chmod 600 ~/.claude/.credentials.json

Request

Please fix claude setup-token to actually save credentials on macOS instead of just printing them.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗