{"record":{"id":"f77405b57bae8324","repo":"AlistGo/alist","slug":"get-token-failed-s","errorCode":null,"errorMessage":"get token failed: %s","messagePattern":"get token failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/kodbox/util.go","lineNumber":24,"sourceCode":"\t\"github.com/alist-org/alist/v3/pkg/utils\"\n\t\"github.com/go-resty/resty/v2\"\n\t\"strings\"\n)\n\nfunc (d *KodBox) getToken() error {\n\tvar authResp CommonResp\n\tres, err := base.RestyClient.R().\n\t\tSetResult(&authResp).\n\t\tSetQueryParams(map[string]string{\n\t\t\t\"name\":     d.UserName,\n\t\t\t\"password\": d.Password,\n\t\t}).\n\t\tPost(d.Address + \"/?user/index/loginSubmit\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif res.StatusCode() >= 400 {\n\t\treturn fmt.Errorf(\"get token failed: %s\", res.String())\n\t}\n\n\tif res.StatusCode() == 200 && authResp.Code.(bool) == false {\n\t\treturn fmt.Errorf(\"get token failed: %s\", res.String())\n\t}\n\n\td.authorization = fmt.Sprintf(\"%s\", authResp.Info)\n\treturn nil\n}\n\nfunc (d *KodBox) request(method string, pathname string, callback base.ReqCallback, noRedirect ...bool) ([]byte, error) {\n\tfull := pathname\n\tif !strings.HasPrefix(pathname, \"http\") {\n\t\tfull = d.Address + pathname\n\t}\n\treq := base.RestyClient.R()\n\tif len(noRedirect) > 0 && noRedirect[0] {\n\t\treq = base.NoRedirectClient.R()","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/kodbox/util.go#L6-L42","documentation":"Raised during KodBox login (getToken) when the POST to /?user/index/loginSubmit returns an HTTP status >= 400. This is a transport/server-level failure before any JSON application code is even inspected — the raw response body is embedded as the error text.","triggerScenarios":"d.Address is wrong or unreachable, KodBox returns 404 (wrong path / missing rewrite rules), 500 (PHP error), 403 (WAF/firewall blocks the login endpoint), or the URL lacks the required scheme.","commonSituations":"Misconfigured site address in the storage config (missing http://, trailing slash issues, pointing at the file page instead of the server); reverse proxy blocking form POST login; KodBox installed without URL rewriting so /?user/index/loginSubmit 404s.","solutions":["Verify d.Address: it must be the KodBox server root reachable over HTTP(S), e.g. https://kod.example.com","Test manually: curl -X POST 'https://<address>/?user/index/loginSubmit' -d 'name=...&password=...' and confirm it is not 4xx/5xx","Fix reverse-proxy/WAF rules that block the login POST, or KodBox rewrite rules if the endpoint 404s"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the address before adding the storage\nu, err := url.Parse(cfg.Address)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") || u.Host == \"\" {\n    return fmt.Errorf(\"invalid kodbox address: %q\", cfg.Address)\n}\nresp, err := http.Head(cfg.Address + \"/?user/index/loginSubmit\")\nif err != nil || resp.StatusCode >= 400 {\n    return fmt.Errorf(\"kodbox login endpoint unreachable (status=%d)\", resp.StatusCode)\n}","typeGuard":null,"tryCatchPattern":"if err := d.getToken(); err != nil {\n    if strings.Contains(err.Error(), \"get token failed\") {\n        // endpoint/server-level issue: do not retry with same config blindly\n        return fmt.Errorf(\"check kodbox address/proxy: %w\", err)\n    }\n    return err\n}","preventionTips":["Smoke-test the login endpoint with curl when configuring the storage","Include the scheme in the address; point at the server root, not a file page","Ensure reverse proxies permit POST to /?user/index/loginSubmit"],"tags":["kodbox","authentication","http-status","configuration","openlist"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}