AlistGo/alist · error

API token is required

Error message

API token is required

What it means

Returned by the Gofile driver's Init when the APIToken additional field is empty. The Gofile API requires a token on every request, so the driver refuses to start rather than fail on each call later.

Source

Thrown at drivers/gofile/driver.go:31

type Gofile struct {
	model.Storage
	Addition

	accountId string
}

func (d *Gofile) Config() driver.Config {
	return config
}

func (d *Gofile) GetAddition() driver.Additional {
	return &d.Addition
}

func (d *Gofile) Init(ctx context.Context) error {
	if d.APIToken == "" {
		return fmt.Errorf("API token is required")
	}

	// Get account ID
	accountId, err := d.getAccountId(ctx)
	if err != nil {
		return fmt.Errorf("failed to get account ID: %w", err)
	}
	d.accountId = accountId

	// Get account info to set root folder if not specified
	if d.RootFolderID == "" {
		accountInfo, err := d.getAccountInfo(ctx, accountId)
		if err != nil {
			return fmt.Errorf("failed to get account info: %w", err)
		}
		d.RootFolderID = accountInfo.Data.RootFolder
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Get a token from Gofile: log in at gofile.io, copy the account token from the admin/API page
  2. Paste it into the driver's 'API token' field in the storage config and save
  3. If configuring via API, ensure the addition JSON includes a non-empty api_token matching the driver's field name

Example fix

// before: empty addition
{"driver":"Gofile","addition":"{\"api_token\":\"\"}"}

// after
{"driver":"Gofile","addition":"{\"api_token\":\"ey...\"}"}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(cfg.APIToken) == "" {
  return errors.New("configure the Gofile API token before enabling this storage")
}

Prevention

When it happens

Trigger: Adding/enabling the Gofile storage driver in admin settings without filling in the API token field, or sending an empty token when programmatically creating the storage.

Common situations: New storage created with defaults; token field cleared when editing other settings; token stored in wrong additional-field key when configuring via API/JSON import.

Related errors


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