From 11bc01e8edef712e21103da2b2bb2cc85d293af3 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Mon, 2 Feb 2026 11:10:31 +0800 Subject: [PATCH] 3 --- backend/internal/auth/codex_api.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/internal/auth/codex_api.go b/backend/internal/auth/codex_api.go index d3aa358..e0f8ae9 100644 --- a/backend/internal/auth/codex_api.go +++ b/backend/internal/auth/codex_api.go @@ -493,6 +493,9 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { return "", fmt.Errorf("密码验证失败: %d", resp.StatusCode) } c.logStep(StepInputPassword, "密码验证成功") + + // 打印密码验证响应,看看服务器返回了什么 + c.logStep(StepInputPassword, "密码验证响应: %s", string(body[:min(500, len(body))])) } else { c.logStep(StepInputPassword, "跳过密码验证步骤 (服务器未要求)") } @@ -503,11 +506,18 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { return "", fmt.Errorf("Sentinel 请求失败") } + // 选择工作区时带上 Sentinel Header + workspaceHeaders := make(map[string]string) + for k, v := range headers { + workspaceHeaders[k] = v + } + workspaceHeaders["OpenAI-Sentinel-Token"] = c.getSentinelHeader("workspace_select") + workspacePayload := map[string]string{ "workspace_id": c.workspaceID, } - resp, body, err = c.doRequest("POST", "https://auth.openai.com/api/accounts/workspace/select", workspacePayload, headers) + resp, body, err = c.doRequest("POST", "https://auth.openai.com/api/accounts/workspace/select", workspacePayload, workspaceHeaders) if err != nil || resp.StatusCode != 200 { c.logError(StepSelectWorkspace, "选择工作区失败: %d - %s", resp.StatusCode, string(body[:min(200, len(body))])) return "", fmt.Errorf("选择工作区失败: %d", resp.StatusCode)