OAuth
OpenClaw 支持 OAuth 认证以使用订阅服务。
支持的 OAuth 流程
Anthropic (Claude)
使用 setup-token 认证:
bash
# 生成 setup-token(在任何机器上运行)
claude setup-token
# 在 OpenClaw 中使用
openclaw models auth setup-token --provider anthropic或粘贴 token:
bash
openclaw models auth paste-token --provider anthropicOpenAI (Codex)
支持 Codex OAuth:
bash
openclaw models auth add
# 选择 OpenAI Codex OAuthGoogle Gemini
使用插件认证流程:
bash
# 启用插件
openclaw plugins enable google-gemini-cli-auth
# 登录
openclaw models auth login --provider google-gemini-cli --set-default认证配置文件
认证信息存储为配置文件:
bash
# 查看认证状态
openclaw models status
# 查看认证顺序
openclaw models auth order get --provider anthropicAPI 密钥 vs OAuth
| API 密钥 | OAuth | |
|---|---|---|
| 来源 | 开发者控制台 | 订阅账户 |
| 计费 | 按使用量 | 订阅费用 |
| 配额 | API 配额 | 订阅配额 |
配置文件优先级
可以控制认证配置文件的尝试顺序:
bash
# 设置顺序
openclaw models auth order set --provider anthropic profile1 profile2
# 清除顺序(使用默认)
openclaw models auth order clear --provider anthropicToken 过期
OAuth token 可能过期。检查状态:
bash
openclaw models status --check退出码:
- 1 = 过期或缺失
- 2 = 即将过期