AlistGo/alist · error

access token is empty

Error message

access token is empty

What it means

Thrown by GuangYaPan.ensureAccessToken when the driver has neither an access token nor a refresh token in storage, and cannot fall back to SMS login (no phone number on record). It means the storage was never fully authenticated. Every GuangYaPan API path funnels through this check, so nothing works until login state exists.

Source

Thrown at drivers/guangyapan/driver.go:538

	if parentID == "" {
		return "", fmt.Errorf("resolve root folder path failed: folder %q not found under /", name)
	}
	return "", fmt.Errorf("resolve root folder path failed: folder %q not found under parent %s", name, parentID)
}

func (d *GuangYaPan) ensureAccessToken(ctx context.Context) error {
	if strings.TrimSpace(d.AccessToken) != "" {
		return nil
	}
	if strings.TrimSpace(d.RefreshToken) == "" {
		if d.canSMSLogin() {
			return d.loginBySMSCode(ctx)
		}
		if d.PhoneNumber != "" {
			return errors.New("not logged in yet: please fill verify_code and save storage to finish SMS login")
		}
		return errors.New("access token is empty")
	}
	return d.refreshToken(ctx)
}

func (d *GuangYaPan) validateToken(ctx context.Context) error {
	var me userMeResp
	resp, err := d.accountClient.R().
		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) == "" {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Re-open the storage config in the admin UI and complete authentication so access_token (or at least refresh_token) is persisted
  2. If the driver supports SMS login, fill in the phone number field so ensureAccessToken can route to loginBySMSCode instead of failing
  3. If a refresh token exists in another environment, copy the full driver storage JSON (tokens included) into this storage entry
  4. Verify with a read-only List call that the error disappears after tokens are saved
Defensive patterns

Strategy: validation

Validate before calling

// before any GuangYaPan call, confirm the storage carries credentials
if d.AccessToken == "" && d.RefreshToken == "" && d.PhoneNumber == "" {
	return errors.New("guangyapan storage is not logged in: configure tokens or phone for SMS login")
}

Type guard

func isGuangYaPanUnauthenticated(d *GuangYaPan) bool {
	return strings.TrimSpace(d.AccessToken) == "" &&
		strings.TrimSpace(d.RefreshToken) == "" &&
		strings.TrimSpace(d.PhoneNumber) == ""
}

Prevention

When it happens

Trigger: Calling any GuangYaPan operation (List, offline resolve, upload, etc.) on a freshly added storage where access_token and refresh_token are both blank in the driver storage and the SMS-login preconditions (phone + canSMSLogin) are absent. It is the terminal branch of ensureAccessToken: TrimSpace(AccessToken)=="" AND TrimSpace(RefreshToken)=="" AND !canSMSLogin() AND PhoneNumber=="".

Common situations: New GuangYaPan mount left half-configured; tokens wiped by a storage reset or a failed migration; SMS login started but verify_code never supplied in a previous session.

Related errors


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