chenhg5/cc-connect · error
wecom: request access_token: %w
Error message
wecom: request access_token: %w
What it means
Transport-level failure of GET /cgi-bin/gettoken: the HTTP request for a new access_token did not complete (network error, DNS failure, TLS issue, timeout). It only fires after the cached token was found expired/absent, so every WeCom API call behind it will also fail until resolved.
Source
Thrown at platform/wecom/wecom.go:672
return nil
}
func (p *Platform) getAccessToken() (string, error) {
p.tokenCache.mu.Lock()
defer p.tokenCache.mu.Unlock()
if p.tokenCache.token != "" && time.Now().Before(p.tokenCache.expiresAt) {
return p.tokenCache.token, nil
}
apiURL := p.wecomAPIURL("/cgi-bin/gettoken", url.Values{
"corpid": []string{p.corpID},
"corpsecret": []string{p.corpSecret},
})
resp, err := p.apiClient.Get(apiURL)
if err != nil {
return "", fmt.Errorf("wecom: request access_token: %w", err)
}
defer resp.Body.Close()
var result struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return "", fmt.Errorf("wecom: decode token response: %w", err)
}
if result.ErrCode != 0 {
return "", fmt.Errorf("wecom: get token failed: %d %s", result.ErrCode, result.ErrMsg)
}
// Compute the cache window from expires_in with a 60-second safety
// margin. When the server omits or zeroes the field, fall back toView on GitHub (pinned to 4000b2338a)
Solutions
- Retry the token fetch with backoff; transient outages self-heal
- Check outbound connectivity and proxy config for qyapi.weixin.qq.com
- Ensure corpid/corpsecret are set so the URL is well-formed
- Log at error level since all platform sends depend on this token
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at platform/wecom/wecom.go:672 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/8c95d60c68f8864a.
Report an issue: GitHub.