Fix: Claude Code OAuth Login Paste Not Working

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

The Error

You run claude on a fresh machine, choose Claude account with subscription, copy the OAuth authorization URL into a browser, complete the flow, and try to paste the auth code back into the terminal prompt:

Paste code here if prompted >

Nothing appears. Pressing Enter does nothing or submits an empty value. The login flow cannot complete.

Quick Fix

Skip the broken login widget entirely using CLAUDE_CODE_OAUTH_TOKEN:

# On a machine where login works (e.g., your Mac)
claude setup-token
# Copy the printed sk-ant-oat01-... token

# On the affected machine
export CLAUDE_CODE_OAUTH_TOKEN="sk-ant-oat01-..."
claude

Claude Code recognizes the environment variable, bypasses the login screen, and starts normally.

What’s Happening

The OAuth login screen uses a different TUI input widget than the main Claude Code chat prompt. This widget does not properly handle bracketed paste escape sequences that modern terminals send when you paste from clipboard.

When you paste text, your terminal wraps it in escape markers:

\x1b[200~<pasted text>\x1b[201~

The main chat prompt handles these correctly. The login input widget does not. Each character of the bracketed-paste payload is processed as an individual keystroke, and:

  1. The leading \x1b[200~ is interpreted as an escape-then-command-key sequence and discarded
  2. The input reader has length or character validation that rejects the burst of characters
  3. Per-keystroke re-renders race with the input buffer and drop characters

This is confirmed by the fact that typing the auth code one character at a time works (but is impractical for 100+ character codes), and pasting into the main chat prompt in the exact same terminal session works fine.

Step-by-Step Solution

# Step 1: On a working machine, generate a long-lived token
claude setup-token

# Step 2: On the affected machine, set the env var persistently
echo 'export CLAUDE_CODE_OAUTH_TOKEN="sk-ant-oat01-YOUR-TOKEN-HERE"' >> ~/.bashrc
source ~/.bashrc

# Step 3: Verify
claude --version

Option 2: Copy Credentials File

# On a working machine, after successful login
cat ~/.claude/.credentials.json

# Copy the JSON content to the affected machine
mkdir -p ~/.claude
# Paste the credentials JSON into ~/.claude/.credentials.json

Option 3: Type the Code Manually

If you have no other machine available, you can type the auth code character by character. The code from the OAuth callback URL looks like:

https://platform.claude.com/oauth/callback?code=AUTH_CODE_HERE

Copy just the code parameter value. Type it into the prompt one character at a time. This works but is tedious for long codes.

Option 4: Use an API Key Instead

If you have API access via console.anthropic.com:

export ANTHROPIC_API_KEY="sk-ant-api03-..."
claude

This bypasses OAuth entirely and uses direct API authentication.

Prevention

Tools That Help

If you are debugging authentication issues across multiple development environments, a browser extension dev tool can help inspect OAuth callback URLs and extract auth codes from redirect chains.