diff --git a/backend/internal/auth/codex_api.go b/backend/internal/auth/codex_api.go index ecf250c..1135ed2 100644 --- a/backend/internal/auth/codex_api.go +++ b/backend/internal/auth/codex_api.go @@ -379,11 +379,24 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { // 解析 continue_url wsResp, _ := client.ReadBody(resp) + c.logStep(StepSelectWorkspace, "工作区响应: %s", string(wsResp)) + var wsResult struct { ContinueURL string `json:"continue_url"` + Page struct { + Type string `json:"type"` + } `json:"page"` + Error string `json:"error"` + Message string `json:"message"` } - if err := json.Unmarshal(wsResp, &wsResult); err != nil || wsResult.ContinueURL == "" { - c.logError(StepSelectWorkspace, "未获取到 continue_url") + if err := json.Unmarshal(wsResp, &wsResult); err != nil { + c.logError(StepSelectWorkspace, "解析响应失败: %v, 原始: %s", err, string(wsResp)) + return "", fmt.Errorf("解析响应失败: %v", err) + } + + if wsResult.ContinueURL == "" { + c.logError(StepSelectWorkspace, "未获取到 continue_url, page=%s, error=%s, msg=%s", + wsResult.Page.Type, wsResult.Error, wsResult.Message) return "", fmt.Errorf("未获取到 continue_url") }