直连接口测试成功

This commit is contained in:
2026-04-23 04:36:57 +08:00
parent 5bc69bcd5b
commit a1587b8d12
15 changed files with 2694 additions and 7 deletions

41
登录.md Normal file
View File

@@ -0,0 +1,41 @@
抓到了。结论很明确CodeBuddy CLI 拿 `ac/rt` 不是本地 OAuth callback而是 **state 轮询模式**
流程:
1. CLI 请求:
`POST https://copilot.tencent.com/v2/plugin/auth/state?platform=CLI`
返回:
- `data.state`
- `data.authUrl`
2. CLI 把登录 URL 给用户打开:
`https://copilot.tencent.com/login?platform=CLI&state=...`
3. CLI 每秒轮询:
`GET https://copilot.tencent.com/v2/plugin/auth/token?state=...`
4. 登录完成后,这个接口返回:
- `accessToken`
- `refreshToken`
- `tokenType: Bearer`
- `expiresIn`
- `refreshExpiresIn`
- `sessionState`
- `scope: openid profile offline_access email`
- `domain`
5. 然后 CLI 用 `Authorization: Bearer <accessToken>` 请求:
- `GET /v2/plugin/login/account?state=...`
- `GET /v2/plugin/accounts`
6. 最后写入:
`~/.local/share/CodeBuddyExtension/Data/Public/auth/Tencent-Cloud.coding-copilot.info`
抓包文件已保存到:[codebuddy-auth-flow.redacted.jsonl](/home/wolves/project/codebuddy2api/captures/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`