{"record":{"id":"d37065d668b1c5f9","repo":"AlexxIT/go2rtc","slug":"auth-request-failed-with-status-d-s","errorCode":null,"errorMessage":"auth request failed with status %d: %s","messagePattern":"auth request failed with status (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":306,"sourceCode":"\t\t}\n\n\t\tif tfaResp.TSVState != \"\" {\n\t\t\tprompt := \"from your authenticator app\"\n\t\t\tif tfaResp.TSVState != \"totp\" {\n\t\t\t\tprompt = fmt.Sprintf(\"sent to %s via %s\", tfaResp.Phone, tfaResp.TSVState)\n\t\t\t}\n\t\t\tc.PromptFor2FA = fmt.Sprintf(\"Please enter the code %s\", prompt)\n\t\t} else {\n\t\t\tc.PromptFor2FA = \"Please enter the code sent to your text/email\"\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"2FA required\")\n\t}\n\n\t// Handle errors\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn nil, fmt.Errorf(\"auth request failed with status %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar authResp AuthTokenResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&authResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode auth response: %w\", err)\n\t}\n\n\t// Refresh token and expiry\n\tc.authToken = &authResp\n\tc.authConfig = &AuthConfig{\n\t\tRT:  authResp.RefreshToken,\n\t\tHID: c.hardwareID,\n\t}\n\t// Set token expiry (1 minute before actual expiry)\n\texpiresIn := time.Duration(authResp.ExpiresIn-60) * time.Second\n\tc.tokenExpiry = time.Now().Add(expiresIn)\n\n\tc.RefreshToken = encodeAuthConfig(c.authConfig)","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L288-L324","documentation":"The Ring OAuth token request returned a non-200 status (excluding the handled 2FA cases). The response body is included in the error to expose the server's reason; wraps nothing — it is a plain status/body report from the auth flow.","triggerScenarios":"Thrown at pkg/ring/api.go:306 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check credentials and app user-agent assumptions","Wait and retry if rate limited (429)","Inspect the body for the specific OAuth error"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}