This commit is contained in:
2026-02-02 09:39:18 +08:00
parent bc95bed6b7
commit a5407cdb25

View File

@@ -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))