AlistGo/alist · error

e.Error

Error message

e.Error

What it means

Google Photo OAuth refresh failure: the token endpoint answered with an error string (typically invalid_grant or invalid_client) which the driver returns verbatim. Same shape as the Drive refresh error but on the Photos driver's refresh_token flow.

Source

Thrown at drivers/google_photo/util.go:35

	FETCH_SHARE_ALBUMS = "share_albums"
)

func (d *GooglePhoto) refreshToken() error {
	url := "https://www.googleapis.com/oauth2/v4/token"
	var resp base.TokenResp
	var e TokenError
	_, err := base.RestyClient.R().SetResult(&resp).SetError(&e).
		SetFormData(map[string]string{
			"client_id":     d.ClientID,
			"client_secret": d.ClientSecret,
			"refresh_token": d.RefreshToken,
			"grant_type":    "refresh_token",
		}).Post(url)
	if err != nil {
		return err
	}
	if e.Error != "" {
		return fmt.Errorf(e.Error)
	}
	d.AccessToken = resp.AccessToken
	return nil
}

func (d *GooglePhoto) request(url string, method string, callback base.ReqCallback, resp interface{}, headers map[string]string) ([]byte, error) {
	req := base.RestyClient.R()
	req.SetHeader("Authorization", "Bearer "+d.AccessToken)
	req.SetHeader("Accept-Encoding", "gzip")
	if headers != nil {
		req.SetHeaders(headers)
	}

	if callback != nil {
		callback(req)
	}
	if resp != nil {
		req.SetResult(resp)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Re-authenticate to obtain a new refresh token
  2. Match client_id/client_secret to the project that issued the token
  3. Publish the OAuth app or add test users if in testing status
  4. Verify server time via NTP
Defensive patterns

Strategy: try-catch

Type guard

func isPhotosTokenDead(err error) bool {
  return err != nil && strings.Contains(err.Error(), "invalid_grant")
}

Try / catch

if err := d.refreshToken(); err != nil {
  if isPhotosTokenDead(err) { /* route user to re-consent; no automated retry will succeed */ }
}

Prevention

When it happens

Trigger: refreshToken with a revoked/expired refresh token, wrong client secret, or consent-screen app in testing mode (refresh tokens expire in 7 days) — Google returns error in the token response and the driver propagates it.

Common situations: User revoked access via Google Account security page; client secret rotated; refresh token minted by a different OAuth client; system clock drift.

Related errors


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