{"record":{"id":"4aa3fe9dcdf30f9d","repo":"AlistGo/alist","slug":"api-token-is-required","errorCode":null,"errorMessage":"API token is required","messagePattern":"API token is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/gofile/driver.go","lineNumber":31,"sourceCode":"\ntype Gofile struct {\n\tmodel.Storage\n\tAddition\n\n\taccountId string\n}\n\nfunc (d *Gofile) Config() driver.Config {\n\treturn config\n}\n\nfunc (d *Gofile) GetAddition() driver.Additional {\n\treturn &d.Addition\n}\n\nfunc (d *Gofile) Init(ctx context.Context) error {\n\tif d.APIToken == \"\" {\n\t\treturn fmt.Errorf(\"API token is required\")\n\t}\n\n\t// Get account ID\n\taccountId, err := d.getAccountId(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get account ID: %w\", err)\n\t}\n\td.accountId = accountId\n\n\t// Get account info to set root folder if not specified\n\tif d.RootFolderID == \"\" {\n\t\taccountInfo, err := d.getAccountInfo(ctx, accountId)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get account info: %w\", err)\n\t\t}\n\t\td.RootFolderID = accountInfo.Data.RootFolder\n\t}\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/gofile/driver.go#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Get a token from Gofile: log in at gofile.io, copy the account token from the admin/API page","Paste it into the driver's 'API token' field in the storage config and save","If configuring via API, ensure the addition JSON includes a non-empty api_token matching the driver's field name"],"exampleFix":"// before: empty addition\n{\"driver\":\"Gofile\",\"addition\":\"{\\\"api_token\\\":\\\"\\\"}\"}\n\n// after\n{\"driver\":\"Gofile\",\"addition\":\"{\\\"api_token\\\":\\\"ey...\\\"}\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(cfg.APIToken) == \"\" {\n  return errors.New(\"configure the Gofile API token before enabling this storage\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the token field as required in any storage-creation automation","Fetch the token from gofile.io admin page at setup time and store it in a secret manager"],"tags":["gofile","config","auth","token"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}