AlistGo/alist · error

oauth2: server response error

Error message

oauth2: server response error

What it means

The FebBox token endpoint answered HTTP 200 but its JSON envelope carries Code != 1, meaning the API rejected the token request (invalid client_id/secret or bad authorization code). The server's msg field is ignored, so only this generic error surfaces.

Solutions

  1. 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:67 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/9adafdf6ca8934a2. Report an issue: GitHub.

Appendix: source

Thrown at drivers/febbox/oauth2.go:67

	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
	}

	if tokenResp.Code != 1 {
		return nil, errors.New("oauth2: server response error")
	}

	c.refreshToken = tokenResp.Data.RefreshToken

	token := &oauth2.Token{
		AccessToken:  tokenResp.Data.AccessToken,
		TokenType:    tokenResp.Data.TokenType,
		RefreshToken: tokenResp.Data.RefreshToken,
		Expiry:       time.Now().Add(time.Duration(tokenResp.Data.ExpiresIn) * time.Second),
	}

	return token, nil
}

func (d *FebBox) initializeOAuth2Token(ctx context.Context, oauth2Config *clientcredentials.Config, refreshToken string) {
	d.oauth2Token = oauth2.ReuseTokenSource(nil, &customTokenSource{
		config:       oauth2Config,
		ctx:          ctx,

View on GitHub (pinned to 843d9dc814)