chenhg5/cc-connect · error
weibo: parse token response: %w
Error message
weibo: parse token response: %w
What it means
The Weibo OAuth token endpoint returned HTTP 200 but its body is not valid JSON matching the tokenResponse struct (e.g. an HTML login page, empty body, or a schema change), so json.Unmarshal failed while refreshing the platform access token in refreshToken.
Source
Thrown at platform/weibo/weibo.go:182
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, nil
}
func (p *Platform) getToken() (string, error) {
p.tokenMu.Lock()
tok := p.tokenView on GitHub (pinned to 4000b2338a)
Solutions
- Log the raw response body (truncated/redacted) alongside the unmarshal error to see what the endpoint actually returned
- Check that the configured Weibo app credentials (app_id/secret) are correct, since an auth failure can return a non-JSON error page with 200
- Verify the tokenResponse struct still matches the current Weibo API schema
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at platform/weibo/weibo.go:182 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/3d5a66e3e7c3bcc6.
Report an issue: GitHub.