Files
vps-management-bot/memory/2026-03-09.md
2026-03-21 01:10:53 +08:00

2.4 KiB
Raw Blame History

2026-03-09

Claude OAuth 认证失败 (21:00-21:38)

  • 目标: 更新 CLIProxyAPI 的 Claude 认证 (mf0@msn.com)
  • 问题: OAuth 回调一直失败
    • SSH 隧道建立成功 (54545 端口)
    • CLIProxyAPI 在服务器上运行
    • Chrome 访问 OAuth URL 并点击 Authorize
    • 但回调重定向到 localhost:54545/callback 时显示 chrome-error://chromewebdata/
    • 回调请求没有到达服务器
  • 尝试过的方法:
    • CDP 自动化填写邮箱 (失败,无法填写)
    • 手动登出 Maka 账号,重新登录 mf0@msn.com
    • 多次重启 SSH 隧道和 OAuth 进程
    • 使用不同的 OAuth URL (多次生成新的 code_challenge)
  • 根本原因: 不明确,可能是:
    • SSH 隧道转发有问题
    • Chrome 的安全策略阻止了 localhost 回调
    • CLIProxyAPI 的 OAuth 回调监听有问题
  • 最终解决 (21:52 成功):
    • State mismatch 是关键问题: 每次启动 CLIProxyAPI 会生成新的 OAuth state必须用最新的 URL
    • 日志显示 "State mismatch: expected X, got Y" → 说明用了旧 URL
    • Docker 容器缺少配置文件: 容器启动失败因为找不到 /CLIProxyAPI/config.yaml
    • 解决方案:
      1. 创建 config.yaml: port: 8317, api-keys: ["sk-cliproxy-default-key-2026"], auth-dir: "/root/.cli-proxy-api"
      2. 挂载到容器: -v /opt/cliproxy/config.yaml:/CLIProxyAPI/config.yaml:ro
      3. 挂载认证目录: -v /root/.cli-proxy-api:/root/.cli-proxy-api
    • 正确流程:
      1. 启动 CLIProxyAPI (在配置目录下): cd /root/.cli-proxy-api && /tmp/CLIProxyAPI -claude-login -no-browser -oauth-callback-port 54545
      2. 建立 SSH 隧道: ssh -L 54545:127.0.0.1:54545 root@195.128.100.201
      3. 获取最新的 OAuth URL (包含新 state)
      4. Chrome 访问并点击 Authorize
      5. 回调成功 → 认证文件更新
      6. 重启 Docker 容器

CLIProxyAPI Docker 配置 (21:56)

  • 容器启动命令:
    docker run -d --name cli-proxy-api --restart always \
      -p 8317:8317 \
      -v /opt/cliproxy/config.yaml:/CLIProxyAPI/config.yaml:ro \
      -v /root/.cli-proxy-api:/root/.cli-proxy-api \
      eceasy/cli-proxy-api:latest
    
  • 配置文件位置: /opt/cliproxy/config.yaml
  • 认证文件位置: /root/.cli-proxy-api/*.json
  • API 端点: http://195.128.100.201:8317/v1
  • API Key: sk-cliproxy-default-key-2026
  • 可用模型: claude-sonnet-4-6, claude-opus-4-6, gpt-5.4, gemini-2.5-pro 等