
How to Recover Claude Code OAuth Token in 30 Seconds
TL;DR When Claude Code fails over SSH, extract the OAuth token from macOS Keychain. Inject it into CLAUDE_CODE_OAUTH_TOKEN . This restores access in 30 seconds without breaking tmux sessions. Prerequisites macOS (Keychain access required) Claude Code CLI v2.1.45 or later installed SSH access to your Mac or working in a tmux session Ran claude setup-token to generate an OAuth token Problem: SSH Can't Access Keychain Claude Code stores OAuth tokens in macOS Keychain (service name: Claude Code-credentials ). When running over SSH, Keychain is locked and the token is inaccessible. $ echo "test" | claude -p Error: Authentication required. Run 'claude auth login' Running claude auth login opens a browser, which doesn't work over SSH. Solution: Pass the Token via Environment Variable Claude Code prioritizes the CLAUDE_CODE_OAUTH_TOKEN environment variable over Keychain. Extract the token from Keychain and set it as an environment variable to make SSH access work. Step 1: Extract Token from Ke
Continue reading on Dev.to
Opens in a new tab




