Fix Claude Code Login — Cannot Paste Auth Code
TL;DR: Claude Code’s login prompt sometimes does not accept pasted text due to terminal paste bracketing. Disable paste bracketing, type the code manually, or use the
ANTHROPIC_API_KEYenvironment variable instead.
The Problem
When running claude /login, you complete the browser authorization flow and receive a code to paste back into the CLI. But when you try to paste it:
Paste code here if prompted >
Nothing happens. The pasted text does not appear, and pressing Enter gives an empty input error. This is a known regression affecting v2.1.105+ on Linux, WSL, and some macOS terminal configurations.
Why This Happens
Modern terminals use “paste bracketing” — they wrap pasted text in escape sequences (\e[200~....\e[201~) to distinguish it from typed input. Claude Code’s TUI input handler does not always process these escape sequences correctly, causing the pasted text to be silently discarded.
This is tracked as a known bug in the Claude Code repository (issues #47648, #47670, #47656).
The Fix
Step 1 — Try Disabling Paste Bracketing
Before running claude /login, disable paste bracketing in your terminal:
# Disable paste bracketing for the current session
printf '\e[?2004l'
# Then run login
claude /login
Step 2 — Use Manual Typing (Short Codes)
If the auth code is short enough (usually 6-8 characters), type it manually character by character rather than pasting.
Step 3 — Use API Key Authentication Instead
The most reliable workaround is to bypass the browser OAuth flow entirely:
# Get your API key from https://console.anthropic.com/
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
# Add to your shell profile for persistence
echo 'export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"' >> ~/.zshrc
source ~/.zshrc
# Verify Claude Code can authenticate
claude --version
Step 4 — WSL-Specific Fix
If you are using WSL (Windows Subsystem for Linux), there is an additional issue where the WSL terminal does not pass clipboard contents correctly:
# Option 1: Use powershell.exe to get clipboard
CODE=$(powershell.exe -command "Get-Clipboard" | tr -d '\r')
echo "$CODE" | claude /login
# Option 2: Use xclip if X11 is configured
sudo apt install xclip
xclip -o -selection clipboard | claude /login
Step 5 — Verify It Works
# Check authentication status
claude auth status
Expected output:
Authenticated as: [email protected]
Subscription: Pro/Max
API: Anthropic
Common Variations
| Scenario | Cause | Quick Fix |
|---|---|---|
| Paste works in other apps, not Claude | Paste bracketing in TUI | printf '\e[?2004l' before login |
| WSL2 paste broken | WSL clipboard isolation | Use powershell.exe Get-Clipboard pipe |
| Dev Container paste broken | Container terminal limitations | Use ANTHROPIC_API_KEY env var |
| SSH session paste broken | Remote terminal escape handling | Use API key auth or tmux paste |
| Works on v2.1.104, broken on v2.1.105 | Regression in TUI input | Downgrade or use API key auth |
Prevention
- Use API key auth for automated environments: Set
ANTHROPIC_API_KEYin CI/CD, containers, and remote sessions. - Pin working versions: If paste regressions recur, pin to a known working version with
npm install -g @anthropic-ai/[email protected].
Related Issues
- Fix Claude API Error 401 — Unauthorized — Auth token expired or invalid
- Claude Code Config File Location — Where settings and credentials are stored
- Claude Code API Authentication Patterns Guide — Browse all auth guides
Last verified: 2026-04-14. Found an issue? Open a GitHub issue.