{"record":{"id":"8a7cab6f8c78a01f","repo":"AlexxIT/go2rtc","slug":"failed-to-decode-auth-response-w","errorCode":null,"errorMessage":"failed to decode auth response: %w","messagePattern":"failed to decode auth response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":311,"sourceCode":"\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)\n\tif c.onTokenRefresh != nil {\n\t\tc.onTokenRefresh(c.RefreshToken)\n\t}\n\n\t// Refresh the cached client","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L293-L329","documentation":"After a successful (200) auth response, JSON decoding of the body into AuthTokenResponse failed, meaning Ring returned a 200 whose body is not a valid token payload. Wraps the decoder error; login cannot complete.","triggerScenarios":"Thrown at pkg/ring/api.go:311 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the auth request","Capture the raw response body to identify API changes and update the struct"],"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"}