AlistGo/alist · error

refresh_token is empty

Error message

refresh_token is empty

What it means

refreshToken refuses to run when driver.storage has no refresh_token. It is a hard precondition: the OAuth-style refresh grant (POST /v1/auth/token with grant_type=refresh_token) is impossible without it, and the driver deliberately fails fast instead of sending a doomed request. Usually surfaced after ensureAccessToken found the access token empty and delegated here.

Source

Thrown at drivers/guangyapan/driver.go:564

		SetContext(ctx).
		SetHeader("Authorization", "Bearer "+d.AccessToken).
		SetResult(&me).
		Get("/v1/user/me")
	if err != nil {
		return err
	}
	if resp.IsError() {
		return fmt.Errorf("validate token failed: status=%d body=%s", resp.StatusCode(), resp.String())
	}
	if strings.TrimSpace(me.Sub) == "" {
		return errors.New("validate token failed: empty user sub")
	}
	return nil
}

func (d *GuangYaPan) refreshToken(ctx context.Context) error {
	if strings.TrimSpace(d.RefreshToken) == "" {
		return errors.New("refresh_token is empty")
	}

	var out tokenResp
	resp, err := d.accountClient.R().
		SetContext(ctx).
		SetBody(map[string]any{
			"client_id":     d.ClientID,
			"grant_type":    "refresh_token",
			"refresh_token": d.RefreshToken,
		}).
		SetResult(&out).
		Post("/v1/auth/token")
	if err != nil {
		return err
	}
	if resp.IsError() || out.Error != "" || strings.TrimSpace(out.AccessToken) == "" {
		errMsg := strings.TrimSpace(out.ErrorDesc)
		if errMsg == "" {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Restore or re-enter a valid refresh_token in the GuangYaPan storage config, then retry the operation
  2. If the refresh token was revoked server-side, redo the full SMS login to obtain a new token pair
  3. Check for code paths or scripts that save driver storage with an empty RefreshToken field and fix them
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(d.RefreshToken) == "" {
	return errors.New("cannot refresh guangyapan token: refresh_token missing from storage")
}

Prevention

When it happens

Trigger: ensureAccessToken reaches refreshToken because access_token is blank but refresh_token is also blank (race with the SMS branch above), or postAPI got a 401/403 and called refreshToken on a storage whose refresh_token field was cleared. Condition: strings.TrimSpace(d.RefreshToken)=="".

Common situations: Token pair was half-deleted during manual storage editing; provider invalidated and the driver previously overwrote RefreshToken with an empty value; copy-paste of storage config dropped the refresh_token key.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/346f0f651e1bcfb2. Report an issue: GitHub.