claude setup-token outputs OAuth token wrapped across two lines, breaks copy-paste

Resolved 💬 3 comments Opened Apr 29, 2026 by fantastiskm Closed May 31, 2026

What happened

Running claude setup-token prints the generated OAuth token wrapped across two lines instead of a single line. Selecting the visible value with the mouse and copying it captures the embedded line break, which produces a malformed token.

Pasting that value into a secret store (e.g. CLAUDE_CODE_OAUTH_TOKEN in GitHub Actions) and using it later results in a 401 from the Anthropic API:

\\\
Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}
\
\\

The CLI itself reports the token is set with a plausible length (80 chars in our case), so the failure is not obvious from local diagnostics — it only surfaces when the API rejects it.

What I expected

The token should be printed as a single, unwrapped line so it can be copied verbatim. Either:

  • emit it on its own line with no formatting, or
  • emit it surrounded by clear delimiters (e.g. \BEGIN TOKEN\ / \END TOKEN\) so users know the exact byte boundaries to copy.

Repro

  1. \claude setup-token\ (with a Pro/Max account)
  2. Complete the browser OAuth flow
  3. Observe that the printed token visually wraps across two terminal lines
  4. Mouse-select and copy the value, paste into a GitHub Actions secret
  5. From CI, run \claude --print\ with that secret as \CLAUDE_CODE_OAUTH_TOKEN\ → 401 invalid bearer token

Environment

  • CLI version: \2.1.123 (Claude Code)\
  • macOS default Terminal.app

Suggested fix

Bypass any line-wrap-aware printer for the token output (e.g. write raw to stdout via \process.stdout.write(token + '\n')\) and consider printing a short instruction line above it explaining how to copy it safely.

View original on GitHub ↗

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