openclaw - ✅(Solved) Fix BUG: Anthropic type: "token" auth profiles broken in v2026.3.28 — classified as OAuth, causes HTTP 401 [1 pull requests, 6 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#57956Fetched 2026-04-08 01:55:44
View on GitHub
Comments
6
Participants
3
Timeline
11
Reactions
2
Author
Timeline (top)
commented ×4cross-referenced ×2labeled ×2closed ×1

After upgrading from v2026.3.24 to v2026.3.28, Anthropic auth fails with HTTP 401 "OAuth authentication is currently not supported" for setups using a type: "token" auth profile with a sops SecretRef (tokenRef). The root cause is a breaking change in 3.28's credential classification logic: mode: "token" is now routed as "oauth" instead of being preserved as its own category, causing the gateway to send Authorization: Bearer instead of x-api-key.

Error Message

2026-03-30T11:55:47.952-07:00 [agent/embedded] embedded run agent end: runId=boot-... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:9c4a9fdae5b9"}

2026-03-30T11:55:49.467-07:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-opus-4-6 candidate=anthropic/claude-opus-4-6 reason=auth next=anthropic/claude-sonnet-4-6

2026-03-30T11:57:05.074-07:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:b543065bb2db"}

Additional context from 3.24 logs (current version):

[agent/embedded] ignoring context1m for OAuth token auth on anthropic/claude-sonnet-4-6

This confirms that even on 3.24, isAnthropicOAuthApiKey() classifies the token as OAuth via prefix detection — but 3.24 still routes the request correctly as API key. In 3.28, the new entry.mode === "token" → "oauth" classification makes this fatal.

Root Cause

After upgrading from v2026.3.24 to v2026.3.28, Anthropic auth fails with HTTP 401 "OAuth authentication is currently not supported" for setups using a type: "token" auth profile with a sops SecretRef (tokenRef). The root cause is a breaking change in 3.28's credential classification logic: mode: "token" is now routed as "oauth" instead of being preserved as its own category, causing the gateway to send Authorization: Bearer instead of x-api-key.

Fix Action

Fix / Workaround

Additionally — a secondary check in isAnthropicOAuthApiKey() detects the sk-ant-oat prefix in the resolved token value and further reinforces OAuth routing, making config-level workarounds (e.g. changing mode to "api_key") ineffective — the token prefix check fires regardless of profile config.

High / Blocking — Any setup using type: "token" with sops SecretRef auth cannot upgrade to 3.28. All API calls fail with 401. No config-level workaround available due to the secondary isAnthropicOAuthApiKey() prefix check overriding explicit profile classification.

PR fix notes

PR #57962: fix: restore token mode for Anthropic auth

Description (problem / solution / changelog)

Summary

Restore the v2026.3.24 behavior where type: "token" auth profiles are preserved as a distinct mode and routed as API key (x-api-key header) rather than being classified as OAuth (Authorization: Bearer header).

Changes

  • Modified the credential classification logic in resolveAnthropicDefaultAuthMode() to preserve "token" mode as distinct from "oauth"
  • Token mode profiles now route as API key instead of OAuth

Testing

Verified that type: "token" profiles now correctly route as API key.

Fixes openclaw/openclaw#57956

Changed files

  • src/config/defaults.ts (modified, +8/-4)

Code Example

2026-03-30T11:55:47.952-07:00 [agent/embedded] embedded run agent end: runId=boot-... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:9c4a9fdae5b9"}

2026-03-30T11:55:49.467-07:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-opus-4-6 candidate=anthropic/claude-opus-4-6 reason=auth next=anthropic/claude-sonnet-4-6

2026-03-30T11:57:05.074-07:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:b543065bb2db"}

Additional context from 3.24 logs (current version):

[agent/embedded] ignoring context1m for OAuth token auth on anthropic/claude-sonnet-4-6

This confirms that even on 3.24, isAnthropicOAuthApiKey() classifies the token as OAuth via prefix detection — but 3.24 still routes the request correctly as API key. In 3.28, the new entry.mode === "token""oauth" classification makes this fatal.
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After upgrading from v2026.3.24 to v2026.3.28, Anthropic auth fails with HTTP 401 "OAuth authentication is currently not supported" for setups using a type: "token" auth profile with a sops SecretRef (tokenRef). The root cause is a breaking change in 3.28's credential classification logic: mode: "token" is now routed as "oauth" instead of being preserved as its own category, causing the gateway to send Authorization: Bearer instead of x-api-key.

Steps to reproduce

  1. Configure an Anthropic auth profile using type: "token" with a sops SecretRef:

{ "auth": { "profiles": { "anthropic:my-profile": { "provider": "anthropic", "type": "token", "tokenRef": { "id": "anthropic_token", "source": "sops" } } } } }

  1. Upgrade from v2026.3.24 → v2026.3.28
  2. Send any message — auth fails with HTTP 401

Expected behavior

type: "token" profiles should continue to work as they did on v2026.3.24. The resolved credential should be sent as x-api-key (API key routing), not Authorization: Bearer (OAuth routing).

Actual behavior

HTTP 401 from Anthropic API: "OAuth authentication is currently not supported"

Root cause (verified against source)

3.24 behavior (pi-embedded-BaSvmUpW.js):

mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"

type: "token" profiles resolve to mode: "token" — a distinct category, routed as API key.

3.28 behavior (auth-profiles-B5ypC5S-.js):

if (entry.mode === "api_key") return "api_key"; if (entry.mode === "oauth" || entry.mode === "token") return "oauth"; // ← breaking change

type: "token" profiles are now classified as "oauth" and routed with Authorization: Bearer, which Anthropic rejects with 401 unless the token is a true OAuth access token.

Additionally — a secondary check in isAnthropicOAuthApiKey() detects the sk-ant-oat prefix in the resolved token value and further reinforces OAuth routing, making config-level workarounds (e.g. changing mode to "api_key") ineffective — the token prefix check fires regardless of profile config.

OpenClaw version

2026.3.28 (regression from 2026.3.24)

Operating system

Ubuntu 24.04 LTS (Linux 6.18.7 x64)

Install method

npm global

Model

anthropic/claude-opus-4-6 (primary) / anthropic/claude-sonnet-4-6 (fallback)

Provider / routing chain

openclaw → anthropic (direct, sops SecretRef)

Additional provider/model setup details

Auth setup

OAuth token (Claude Max subscription) stored via sops/age encryption, resolved at runtime via SecretRef. Token has sk-ant-oat prefix. Profile configured as type: "token" (not type: "oauth").

Logs, screenshots, and evidence

2026-03-30T11:55:47.952-07:00 [agent/embedded] embedded run agent end: runId=boot-... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:9c4a9fdae5b9"}

2026-03-30T11:55:49.467-07:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=anthropic/claude-opus-4-6 candidate=anthropic/claude-opus-4-6 reason=auth next=anthropic/claude-sonnet-4-6

2026-03-30T11:57:05.074-07:00 [agent/embedded] embedded run agent end: runId=... isError=true model=claude-opus-4-6 provider=anthropic error=HTTP 401 authentication_error: OAuth authentication is currently not supported. rawError=401 {"type":"error","error":{"type":"authentication_error","message":"OAuth authentication is currently not supported."},"request_id":"sha256:b543065bb2db"}

Additional context from 3.24 logs (current version):

[agent/embedded] ignoring context1m for OAuth token auth on anthropic/claude-sonnet-4-6

This confirms that even on 3.24, isAnthropicOAuthApiKey() classifies the token as OAuth via prefix detection — but 3.24 still routes the request correctly as API key. In 3.28, the new entry.mode === "token""oauth" classification makes this fatal.

Impact and severity

High / Blocking — Any setup using type: "token" with sops SecretRef auth cannot upgrade to 3.28. All API calls fail with 401. No config-level workaround available due to the secondary isAnthropicOAuthApiKey() prefix check overriding explicit profile classification.

Additional information

Suggested fix

Either:

  1. Restore the 3.24 behavior — preserve "token" as a distinct mode that routes as API key, not OAuth
  2. Add a new type: "api_key" migration path for setups that use type: "token" with non-OAuth tokens, with a openclaw doctor --fix migration
  3. Make isAnthropicOAuthApiKey() check the profile mode field rather than (or in addition to) the raw token prefix, so explicit mode: "api_key" config can override prefix detection

extent analysis

Fix Plan

To resolve the issue, we will implement the suggested fix by restoring the 3.24 behavior and preserving "token" as a distinct mode that routes as API key, not OAuth. We will also add a new type: "api_key" migration path for setups that use type: "token" with non-OAuth tokens.

Step 1: Update the auth-profiles-B5ypC5S-.js file

// Update the mode classification logic to preserve "token" as a distinct mode
if (entry.mode === "api_key") return "api_key";
if (entry.mode === "oauth") return "oauth";
if (entry.mode === "token") return "token"; // Restore the 3.24 behavior

Step 2: Add a new type: "api_key" migration path

// Add a new migration path for setups that use type: "token" with non-OAuth tokens
if (entry.type === "token" && entry.tokenRef && entry.tokenRef.source === "sops") {
  return "api_key";
}

Step 3: Update the isAnthropicOAuthApiKey() function

// Update the function to check the profile mode field rather than the raw token prefix
function isAnthropicOAuthApiKey(entry) {
  if (entry.mode === "api_key" || entry.mode === "token") {
    return false;
  }
  // Check the token prefix only if the mode is not explicitly set to "api_key" or "token"
  if (entry.token && entry.token.startsWith("sk-ant-oat")) {
    return true;
  }
  return false;
}

Verification

To verify that the fix worked, you can:

  • Upgrade to the updated version of OpenClaw
  • Configure an Anthropic auth profile using type: "token" with a sops SecretRef
  • Send a message and verify that the authentication is successful
  • Check the logs to ensure that the request is routed as API key, not OAuth

Extra Tips

  • Make sure to test the fix thoroughly to ensure that it works as expected
  • Consider adding additional logging or monitoring to detect any potential issues with the authentication flow
  • If you encounter any issues during the migration, you can try setting the mode field explicitly to "api_key" in the auth profile configuration to override the prefix detection.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

type: "token" profiles should continue to work as they did on v2026.3.24. The resolved credential should be sent as x-api-key (API key routing), not Authorization: Bearer (OAuth routing).

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING