Skip to content

[BUG] CLAUDE_CODE_OAUTH_TOKEN ignored when claude --print #5143

@piktur

Description

@piktur

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions