1.5 KiB
1.5 KiB
抓到了。结论很明确:CodeBuddy CLI 拿 ac/rt 不是本地 OAuth callback,而是 state 轮询模式。
流程:
-
CLI 请求:
POST https://copilot.tencent.com/v2/plugin/auth/state?platform=CLI返回:
data.statedata.authUrl
-
CLI 把登录 URL 给用户打开:
https://copilot.tencent.com/login?platform=CLI&state=... -
CLI 每秒轮询:
GET https://copilot.tencent.com/v2/plugin/auth/token?state=... -
登录完成后,这个接口返回:
accessTokenrefreshTokentokenType: BearerexpiresInrefreshExpiresInsessionStatescope: openid profile offline_access emaildomain
-
然后 CLI 用
Authorization: Bearer <accessToken>请求:GET /v2/plugin/login/account?state=...GET /v2/plugin/accounts
-
最后写入:
~/.local/share/CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info
抓包文件已保存到:codebuddy-auth-flow.redacted.jsonl
当前新登录态已经生效。旧登录态备份在:
~/.local/share/CodeBuddyExtension/Data/Public/auth/codex-backup-20260423-032754/
补充:这次没有触发 refresh 接口,因为新拿到的 accessToken 和 refreshToken 过期时间都接近一年后。轻量实现上,首次登录可以复刻这个 state 轮询流程;日常使用直接读这个 auth 文件里的 accessToken 发 Authorization 和 X-API-Key。