{"record":{"id":"f4d80e18708f884c","repo":"AlexxIT/go2rtc","slug":"milesone-authentication-failed","errorCode":null,"errorMessage":"milesone: authentication failed: ","messagePattern":"milesone: authentication failed: ","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/webrtc/milestone.go","lineNumber":54,"sourceCode":"\t\t\"username\":   m.query[\"username\"],\n\t\t\"password\":   m.query[\"password\"],\n\t}\n\n\treq, err := http.NewRequest(\"POST\", m.url+\"/IDP/connect/token\", strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\t// support httpx protocol\n\tres, err := tcp.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn errors.New(\"milesone: authentication failed: \" + res.Status)\n\t}\n\n\tvar payload map[string]interface{}\n\tif err = json.NewDecoder(res.Body).Decode(&payload); err != nil {\n\t\treturn err\n\t}\n\n\ttoken, ok := payload[\"access_token\"].(string)\n\tif !ok {\n\t\treturn errors.New(\"milesone: token not found in the response\")\n\t}\n\n\tm.token = token\n\n\treturn nil\n}\n\nfunc parseFloat(s string) float64 {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/webrtc/milestone.go#L36-L72","documentation":"GetToken performs a login POST to the Milestone Mobile server; any non-200 status is reported as this error with the HTTP status line. It means the Milestone server rejected the authentication request before a session token could be read.","triggerScenarios":"Calling milestoneClient with wrong username/password, a user without Mobile Server access, wrong server address/port, or a gateway returning 401/403/404 instead of the expected OK.","commonSituations":"Password changed in Milestone Management Client; user account disabled; connecting to the wrong port (not the Mobile Server port); reverse proxy stripping auth or returning HTML error pages.","solutions":["Verify Milestone username/password and that the user has Mobile Server (MIP) access rights","Check the server URL/port points to the Milestone Mobile server, not the management server","Inspect res.Status in the message (e.g. 401 Unauthorized) to narrow the cause","Confirm network path/proxy isn't intercepting the request and returning an error page"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"u, err := url.Parse(serverURL)\nif err != nil {\n\treturn err\n}\nif u.Scheme != \"https\" && u.Scheme != \"http\" {\n\treturn errors.New(\"milestone server must be http(s) URL\")\n}","typeGuard":null,"tryCatchPattern":"if err := milestone.GetToken(server, user, pass); err != nil {\n\tif strings.Contains(err.Error(), \"authentication failed: 401\") {\n\t\t// prompt for new credentials\n\t}\n}","preventionTips":["Verify credentials and Mobile Server access rights in Milestone","Point at the Mobile Server port, not the management server","Handle 401 centrally to prompt re-authentication instead of blind retries"],"tags":["go","milestone","authentication","http"],"backgroundTag":"http-non-200-response","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}