Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix: remove (external, cli) user-agent flag that causes setup-token 401#1677

Closed
LazerLance777 wants to merge 2 commits intobadlogic:mainfrom
LazerLance777:fix/setup-token-user-agent-401
Closed

fix: remove (external, cli) user-agent flag that causes setup-token 401#1677
LazerLance777 wants to merge 2 commits intobadlogic:mainfrom
LazerLance777:fix/setup-token-user-agent-401

Conversation

@LazerLance777
Copy link

Problem

When using Claude Max/Pro setup-tokens (sk-ant-oat01-*) via OpenClaw, all API requests fail with HTTP 401 Unauthorized at runtime, even though the auth probe passes. This affects all OpenClaw users with Claude Max/Pro subscriptions.

Tracked in: openclaw/openclaw#23538

Root Cause

The user-agent string for OAuth/setup-token requests includes an (external, cli) flag:

"user-agent": `claude-cli/${claudeCodeVersion} (external, cli)`,

This explicitly tells Anthropic's API server "I am NOT the real Claude Code." Anthropic's server-side validation checks this flag and rejects the request with 401.

Additionally, the hardcoded claudeCodeVersion is "2.1.2" while the current Claude Code version is 2.1.62+.

Fix (2 lines)

  1. Line 65: Update claudeCodeVersion from "2.1.2" to "2.1.62"
  2. Line 543: Remove (external, cli) from the user-agent string

Testing

Tested and confirmed working on:

  • OpenClaw 2026.2.26
  • Claude Code 2.1.62
  • Claude Max subscription
  • macOS (Apple Silicon), Node.js 25.6.1
  • Models: anthropic/claude-sonnet-4-5, anthropic/claude-opus-4-6

LazerLance777 and others added 2 commits February 27, 2026 13:24
The user-agent string for setup-token (OAuth) requests included an
"(external, cli)" flag that explicitly tells Anthropic's API server
"I am NOT the real Claude Code." This caused Anthropic's server-side
validation to reject all setup-token requests with HTTP 401.

Changes:
1. Remove "(external, cli)" from user-agent header (line 543)
2. Update claudeCodeVersion from "2.1.2" to "2.1.62" (line 65)

Fixes openclaw/openclaw#23538
The user-agent string for setup-token (OAuth) requests included an
"(external, cli)" flag that explicitly tells Anthropic's API server
"I am NOT the real Claude Code." This caused Anthropic's server-side
validation to reject all setup-token requests with HTTP 401.

Changes:
1. Remove "(external, cli)" from user-agent header (line 543)
2. Update claudeCodeVersion from "2.1.2" to "2.1.62" (line 65)

Fixes openclaw/openclaw#23538
@github-actions
Copy link
Contributor

Hi @LazerLance777, thanks for your interest in contributing!

We ask new contributors to open an issue first before submitting a PR. This helps us discuss the approach and avoid wasted effort.

Next steps:

  1. Open an issue describing what you want to change and why (keep it concise, write in your human voice, AI slop will be closed)
  2. Once a maintainer approves with lgtm, you'll be added to the approved contributors list
  3. Then you can submit your PR

This PR will be closed automatically. See https://github.com/badlogic/pi-mono/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions bot closed this Feb 27, 2026
badlogic added a commit that referenced this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant