[BUG] CLAUDE_CODE_OAUTH_TOKEN ignored when `claude --print`
Resolved 💬 3 comments Opened Aug 5, 2025 by pikturdev Closed Aug 15, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: Since 1.0.67
- Operating System: Linux c956dfb691a7 6.14.10-orbstack-00291 aarch64 GNU/Linux
- Terminal: xterm-256color
Bug Description
When headless claude --print
And CLAUDE_CODE_OAUTH_TOKEN set in environment
Or present in $HOME/.claude/.credentials.json
Then authenticate with OAuth token
And ignore ANTHROPIC_API_KEY
Steps to Reproduce
# Remove ANTHROPIC_API_KEY
unset ANTHROPIC_API_KEY;
# Install 1.0.68 (latest as of 5 August)
npm install -g @anthropic-ai/claude-code@1.0.68;
claude --version # 1.0.68 (Claude Code)
# Simple test asserts OAuth token usage
echo "ping" | CLAUDE_CODE_OAUTH_TOKEN=$(cat $HOME/.claude/.credentials.json | jq -r '.claudeAiOauth.accessToken') claude -p # Credit balance is too low
Expected Behavior
When headless claude --print
And CLAUDE_CODE_OAUTH_TOKEN set in environment
Or present in $HOME/.claude/.credentials.json
Then authenticate with OAuth token
And ignore ANTHROPIC_API_KEY
Actual Behavior
CLAUDE_CODE_OAUTH_TOKEN is ignored; falls back to ANTHROPIC_API_KEY if present in environment.
Additional Context
Last known good version 1.0.66
Claude Max Subscription (paid to September 2025)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗