Repository navigation
Conversation
When Anthropic setup-token auth is used, the OAuth usage endpoint returns 403 because setup-token only grants user:inference scope, not user:profile. This change: 1. Returns a clear, actionable error message suggesting `claude login` (full OAuth) when the scope error occurs and no web session fallback is available, instead of the generic 'HTTP 403: ...' message. 2. Adds a post-onboard note during setup-token flow warning users that usage tracking in /status requires the full OAuth flow. 3. Adds a test for the no-fallback scope error path. Refs: - anthropics/claude-code#16075 - anthropics/claude-code#15243 - anthropics/claude-code#12020
Contributor
Author
|
Closing in favor of #4894 which addresses the root cause (auto-sync Claude CLI OAuth credentials with refresh token) rather than just warning about the scope limitation. The new PR supersedes this by enabling auto-refresh and preserving all OAuth scopes including user:profile. |
GodsBoy
added a commit
to GodsBoy/openclaw
that referenced
this pull request
Jan 31, 2026
Add Claude Code CLI credential sync to external-cli-sync, matching the existing Qwen CLI pattern. When ~/.claude/.credentials.json contains full OAuth credentials (access + refresh token), they are imported as type: oauth profiles enabling automatic token refresh. Changes: - external-cli-sync.ts: add Claude CLI sync (OAuth + setup-token fallback) - doctor-auth.ts: un-deprecate anthropic:claude-cli profile - external-cli-sync.test.ts: integration tests - isExternalProfileFresh: accept optional provider param Supersedes openclaw#4615. Complements openclaw#4593.
GodsBoy
added a commit
to GodsBoy/openclaw
that referenced
this pull request
Feb 1, 2026
Add Claude Code CLI credential sync to external-cli-sync, matching the existing Qwen CLI pattern. When ~/.claude/.credentials.json contains full OAuth credentials (access + refresh token), they are imported as type: "oauth" profiles enabling automatic token refresh. This solves three problems: 1. Token expiry requires manual re-auth (auto-refresh via refresh token) 2. Re-onboarding with setup-token loses user:profile scope (full OAuth preserves all scopes including usage tracking) 3. No easy path to import Claude Code credentials (automatic sync) Changes: - external-cli-sync.ts: add Claude CLI sync (OAuth + setup-token fallback) - doctor-auth.ts: un-deprecate anthropic:claude-cli profile, update hint to recommend `claude login` for refresh - external-cli-sync.test.ts: integration tests using temp credential files - isExternalProfileFresh: accept optional provider param for multi-CLI use - Refactored Qwen sync to use shared syncExternalCliCredentialsForProvider Supersedes openclaw#4615 (scope hint) by addressing the root cause. Complements openclaw#4593 (don't warn about expired tokens with refresh tokens).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Anthropic
setup-tokenauth is used for onboarding, the OAuth usage endpoint returns HTTP 403 becausesetup-tokenonly grantsuser:inferencescope — notuser:profilewhich is required for usage tracking. Users see a cryptic error in/statuswith no guidance on how to fix it.Changes
1. Actionable error message (
provider-usage.fetch.claude.ts)When the 403 scope error occurs and no
claude.aiweb session fallback is available, return a clear error:Previously, this fell through to the generic
HTTP 403: OAuth token does not meet scope requirement user:profilemessage with no remediation guidance.2. Post-onboard warning (
auth-choice.apply.anthropic.ts)After completing setup-token onboarding, display a note explaining:
setup-tokendoes not includeuser:profilescope/statuswon't work with this tokenclaude loginthenopenclaw models auth paste-token3. New test (
provider-usage.test.ts)Added test for the no-fallback scope error path, verifying the actionable error message is returned when no
CLAUDE_AI_SESSION_KEYis available.Context
Closes #4614
The root cause is upstream in Claude Code CLI —
setup-tokenonly requestsuser:inferencescope whileclaude login(full browser OAuth) requests all scopes includinguser:profile. This PR improves the user experience until/unless the upstream scope issue is resolved.Related Claude Code issues: