From a5407cdb25975c94f731f90fd6bbabd995f72d0a Mon Sep 17 00:00:00 2001 From: kyx236 Date: Mon, 2 Feb 2026 09:39:18 +0800 Subject: [PATCH] 2 --- backend/internal/auth/codex_api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/internal/auth/codex_api.go b/backend/internal/auth/codex_api.go index 1135ed2..71ff5b4 100644 --- a/backend/internal/auth/codex_api.go +++ b/backend/internal/auth/codex_api.go @@ -293,6 +293,7 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { req, _ = http.NewRequest("POST", "https://auth.openai.com/api/accounts/authorize/continue", bytes.NewReader(emailBody)) req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") req.Header.Set("Origin", "https://auth.openai.com") req.Header.Set("Referer", referer) req.Header.Set("OpenAI-Sentinel-Token", c.getSentinelHeader("authorize_continue")) @@ -330,6 +331,7 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { req, _ = http.NewRequest("POST", "https://auth.openai.com/api/accounts/password/verify", bytes.NewReader(pwdBody)) req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") req.Header.Set("Origin", "https://auth.openai.com") req.Header.Set("Referer", referer) req.Header.Set("OpenAI-Sentinel-Token", c.getSentinelHeader("password_verify")) @@ -361,6 +363,7 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { req, _ = http.NewRequest("POST", "https://auth.openai.com/api/accounts/workspace/select", bytes.NewReader(wsBody)) req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") req.Header.Set("Origin", "https://auth.openai.com") req.Header.Set("Referer", referer) @@ -371,6 +374,10 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { } defer resp.Body.Close() + // 调试: 打印响应头信息 + c.logStep(StepSelectWorkspace, "响应状态: %d, Content-Length: %s, Content-Encoding: %s", + resp.StatusCode, resp.Header.Get("Content-Length"), resp.Header.Get("Content-Encoding")) + if resp.StatusCode != 200 { body, _ := client.ReadBody(resp) c.logError(StepSelectWorkspace, "选择工作区失败: %d - %s", resp.StatusCode, string(body))