{"record":{"id":"dc0450e2343998a9","repo":"AlexxIT/go2rtc","slug":"2fa-required","errorCode":null,"errorMessage":"2FA required","messagePattern":"2FA required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":300,"sourceCode":"\t\t}\n\n\t\tc.Using2FA = true\n\t\tif resp.StatusCode == http.StatusBadRequest {\n\t\t\tc.PromptFor2FA = \"Invalid 2fa code entered. Please try again.\"\n\t\t\treturn nil, fmt.Errorf(\"invalid 2FA code\")\n\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,","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L282-L318","documentation":"Control-flow sentinel in the Ring auth flow: the server answered 412/2FA challenge and no code was supplied, so authentication cannot proceed until the user provides one. PromptFor2FA on the client describes what is needed.","triggerScenarios":"Thrown at pkg/ring/api.go:300 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Collect the 2FA code (from PromptFor2FA) and call GetAuth again with twoFactorAuthCode","Switch to refresh-token auth to avoid interactive 2FA"],"exampleFix":null,"handlingStrategy":"validation","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"}