chenhg5/cc-connect · error
weibo: token HTTP %d: %s
Error message
weibo: token HTTP %d: %s
What it means
Non-200 status from the token endpoint, with the raw response body appended: the server processed (or rejected) the token request but answered with an error status instead of the expected 200. The body usually contains the platform's error description — invalid credentials, bad app_id, or server-side incidents — since the JSON error_code path is only reached on 200.
Source
Thrown at platform/weibo/weibo.go:177
req, err := http.NewRequest("POST", p.tokenEndpoint, strings.NewReader(body))
if err != nil {
return "", fmt.Errorf("weibo: build token request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return "", fmt.Errorf("weibo: token request: %w", err)
}
defer resp.Body.Close()
raw, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("weibo: read token response: %w", err)
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("weibo: token HTTP %d: %s", resp.StatusCode, string(raw))
}
var tr tokenResponse
if err := json.Unmarshal(raw, &tr); err != nil {
return "", fmt.Errorf("weibo: parse token response: %w", err)
}
if tr.Data.Token == "" {
return "", fmt.Errorf("weibo: empty token in response: %s", string(raw))
}
p.token = tr.Data.Token
p.tokenExpiry = time.Now().Add(time.Duration(tr.Data.ExpireIn) * time.Second)
if len(tr.Data.UID) > 0 {
p.uid = strings.Trim(string(tr.Data.UID), `"`)
}
slog.Debug(p.tag()+": token refreshed", "expires_in", tr.Data.ExpireIn)
return p.token, nilView on GitHub (pinned to 4000b2338a)
Solutions
- Read the included body text to identify the rejection reason
- For 401/403-style answers, verify app_id/app_secret against the Weibo app console
- For 5xx, retry with backoff and check the provider's status page
- Avoid echoing the full body to users; log it and show a generic i18n error
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at platform/weibo/weibo.go:177 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/70f2015a15865fdd.
Report an issue: GitHub.