Repository navigation
[1402] OAuth 401 刷新修复:access token 原地同步到请求配置,轮换的 refresh token 落盘 - #18
Merged
Merged
Conversation
401 触发的 OAuth 刷新此前只写 auth.json 与返回值,当前请求重试与后续 请求仍携带旧 access token,导致每轮都收到 401 再刷新。新增 pi-cfg-api-key-set! 原地更新配置对象的 api-key,dispatch 规范化时 保留已完整配置的对象身份,oauth-hook 与 tui worker 同步刷新后的 配置容器,使连续请求复用新 token。
- stub_oauth_refresh_request_server.py 期望的 token 从 new-access 改为 stub-access-token-2,与 stub_kimi_oauth_server.py 刷新返回值一致 - 测试期望响应文本同步更新 - 移除对 model-meta 的覆盖,避免 base-url 回退到真实 API 导致 第二次请求发往错误端点
refresh token 轮换(OAuth2)后新 refresh token 必须落盘,否则重启读到旧 (可能已失效)的 refresh token 被迫重新登录。access token 短命仅保留内存。 - oauth-hook: 新增 %persist-refresh!,刷新成功时写回 refresh/expires 并保留 盘上旧 access;invalid_grant 时同时清除内存 store 与 auth.json 条目 - 更新 pi-make-refresh-oauth-hook / pi-request-provider-oauth-refresh 测试断言 - 删除误提交的 code/oauth-test-output.txt 并 gitignore *-test-output.txt
- pi-resolve-provider-key-oauth / pi-make-refresh-oauth-hook / pi-request-provider-oauth-refresh 测试补齐【语法】【参数】【返回值】段落, (check-report) 上方补空行 - 新增 oauth store 7 个导出函数的单测与 README - 新增 pi-oauth-store-for-config / pi-make-request-oauth-key-hook 单测
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
401 触发的 OAuth 刷新此前只写入 `auth.json` 和返回值。当前请求的重试以及后续请求仍携带旧 access token,导致每一轮都再次收到 401 并触发刷新。
改动
ai/config/runtime.scm:新增 `pi-cfg-api-key-set!`,原地更新 `` record 或 alist 中的 `api-key`,保留对象身份。ai/dispatch.scm:`%normalize-config` 对已完整规范化的配置直接返回原对象,避免复制 `model-meta` 致使刷新只写入临时副本。code/config/oauth-hook.scm:刷新成功后用 `pi-cfg-api-key-set!` 把新 access token 同步回当前请求配置。tui/worker.scm:401 刷新原地更新 `job-cfg` 后同步 `eff-box` / `effective-cfg`,下一条消息不再携带旧 token。测试