AlistGo/alist · error
oauth2: cannot fetch token
Error message
oauth2: cannot fetch token
What it means
The FebBox custom OAuth2 token endpoint returned a non-200 HTTP status, so the access token could not be fetched or refreshed. The server's error body is discarded and replaced with this generic message; fires on bad client credentials, revoked apps, or endpoint outages.
Solutions
- Inspect the underlying error details in the message, fix the indicated cause (credentials, network, or provider-side failure), and retry.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at drivers/febbox/oauth2.go:47 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/bf0649c59556dc0a.
Report an issue: GitHub.
Appendix: source
Thrown at drivers/febbox/oauth2.go:47
}
v.Set("client_id", c.config.ClientID)
v.Set("client_secret", c.config.ClientSecret)
req, err := http.NewRequest("POST", c.config.TokenURL, strings.NewReader(v.Encode()))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := http.DefaultClient.Do(req.WithContext(c.ctx))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New("oauth2: cannot fetch token")
}
var tokenResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
AccessToken string `json:"access_token"`
ExpiresIn int64 `json:"expires_in"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
RefreshToken string `json:"refresh_token"`
} `json:"data"`
}
if err := json.NewDecoder(resp.Body).Decode(&tokenResp); err != nil {
return nil, err
}
View on GitHub (pinned to 843d9dc814)