← 返回
开发者工具 中文

Oauth Disguise

Configure Anthropic OAuth tokens (sk-ant-oat01-*) to work as API keys in OpenClaw via environment variable injection, enabling Claude Pro/Team API access.
配置 Anthropic OAuth 令牌(sk-ant-oat01-*)经环境变量注入作为 OpenClaw API 密钥,启用 Claude Pro/Team API 访问。
jiafar
开发者工具 clawhub v1.1.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 564
下载
💾 9
安装
1
版本
#latest

概述

OAuth Token Disguise

Configure Anthropic OAuth tokens (sk-ant-oat01-*) as working API keys through OpenClaw's env.vars injection.

Core Method

Inject token via environment variable, reference with ${VAR} in provider config:

openclaw config patch '{
  "env": {
    "vars": {
      "ANTHROPIC_API_KEY": "sk-ant-oat01-YOUR_TOKEN"
    }
  },
  "models": {
    "providers": {
      "anthropic-official": {
        "baseUrl": "https://api.anthropic.com",
        "apiKey": "${ANTHROPIC_API_KEY}",
        "api": "anthropic-messages",
        "models": [
          {"id": "claude-sonnet-4-20250514", "name": "Claude Sonnet 4"},
          {"id": "claude-opus-4-6", "name": "Claude Opus 4.6"}
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic-official/claude-sonnet-4-20250514"
      }
    }
  }
}'

Then restart: openclaw gateway restart

Per-Agent Configuration

Apply to a single agent (keep others on proxy):

openclaw config patch '{
  "agents": {
    "list": [{
      "id": "YOUR_AGENT_ID",
      "name": "Agent Name",
      "workspace": "/path/to/workspace",
      "model": {"primary": "anthropic-official/claude-opus-4-6"}
    }]
  }
}'

Verification

Run session_status or openclaw status. Look for:

  • 🧠 Model: anthropic-official/* → ✅ success
  • custom-proxy/* or fallback notice → ❌ token invalid or auth cooldown

Troubleshooting

SymptomCauseFix
---------------------
Still shows custom-proxy/*defaults.model.primary wrongSet to anthropic-official/MODEL_ID
Fallback after token switchAuth cooldown from rapid switchingWait 5 min, restart gateway
env variable missingGateway not restartedopenclaw gateway restart
Works then stopsToken expiredReplace token in env.vars, restart

Critical: Do not rapidly switch between tokens. OpenClaw tracks auth failures and applies cooldown periods. If stuck in fallback, use session_status with model parameter to force reset:

/model anthropic-official/claude-opus-4-6

Dual Provider Setup

Keep proxy as fallback while using official API:

{
  "env": {"vars": {"ANTHROPIC_API_KEY": "sk-ant-oat01-xxx"}},
  "models": {
    "providers": {
      "custom-proxy": {
        "baseUrl": "https://your-proxy.com/",
        "apiKey": "proxy-key",
        "api": "anthropic-messages",
        "models": [{"id": "claude-sonnet-4-5", "name": "Claude Sonnet 4.5"}]
      },
      "anthropic-official": {
        "baseUrl": "https://api.anthropic.com",
        "apiKey": "${ANTHROPIC_API_KEY}",
        "api": "anthropic-messages",
        "models": [
          {"id": "claude-sonnet-4-20250514", "name": "Claude Sonnet 4"},
          {"id": "claude-opus-4-6", "name": "Claude Opus 4.6"}
        ]
      }
    }
  }
}

Security

  • Tokens auto-redacted in config.get output (__OPENCLAW_REDACTED__)
  • Direct curl with these tokens fails (only works through OpenClaw)
  • Never commit openclaw.json with raw tokens to version control
  • Use env.vars (not inline apiKey) to keep tokens in one place

版本历史

共 1 个版本

  • v1.1.1 当前
    2026-03-19 22:11 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

suspicious
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,519
ai-intelligence

Amazon Scraper

jiafar
高性能容器化 Amazon 爬虫(Docker + playwright-extra + Stealth 插件),可绕过 Amazon 头检检测,支持 Amazon BSR、搜索结果等。
★ 6 📥 3,152
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,937