-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Open
Description
Problem
Anthropic OAuth authentication repeatedly fails with authentication_error: invalid x-api-key after initial setup.
Root Cause
The Anthropic OAuth profile in ~/.openclaw/agents/main/agent/auth-profiles.json is missing critical fields:
"anthropic:default": {
"type": "token",
"provider": "anthropic",
"token": "sk-ant-oat01-..."
// Missing: "refresh" field
// Missing: "expires" field
}Compare to working OAuth providers:
"openai-codex:default": {
"type": "oauth",
"provider": "openai-codex",
"access": "...",
"refresh": "rt_...",
"expires": 1771821456189
}Impact
- OAuth access tokens expire (typically within hours/days)
- Without refresh token, OpenClaw cannot renew the token
- User must re-authenticate repeatedly (
openclaw configure) - Re-authentication doesn't fix the issue - refresh token still not saved
- Wastes user's Max plan quota or forces fallback to paid API keys
Steps to Reproduce
- Run
openclaw configure - Add Anthropic OAuth provider
- Complete OAuth flow in browser
- Check
~/.openclaw/agents/main/agent/auth-profiles.json - Note missing
refreshandexpiresfields - Wait a few hours
- Anthropic API calls fail with
authentication_error
Expected Behavior
Anthropic OAuth profile should include:
refreshtoken for automatic token renewalexpirestimestamp for proactive refresh- Automatic token refresh before expiration
Environment
- OpenClaw version: 2026.2.6-3
- Node version: v22.22.0
- OS: Linux (Ubuntu/Debian)
Workaround
None. User must either:
- Use a different provider (GitHub Copilot, Google, etc.)
- Manually re-authenticate every few hours (unsustainable)
Request
Please update Anthropic OAuth implementation to match OpenAI/Google OAuth patterns - save and use refresh tokens.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels