{"record":{"id":"5bb35cfade438ce4","repo":"AlexxIT/go2rtc","slug":"invalid-2fa-code","errorCode":null,"errorMessage":"invalid 2FA code","messagePattern":"invalid 2FA code","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":287,"sourceCode":"\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Handle 2FA Responses\n\tif resp.StatusCode == http.StatusPreconditionFailed ||\n\t\t(resp.StatusCode == http.StatusBadRequest && strings.Contains(resp.Header.Get(\"WWW-Authenticate\"), \"Verification Code\")) {\n\n\t\tvar tfaResp Auth2faResponse\n\t\tif err := json.NewDecoder(resp.Body).Decode(&tfaResp); err != nil {\n\t\t\treturn nil, err\n\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)","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L269-L305","documentation":"The Ring OAuth endpoint responded 400 with a 'Verification Code' WWW-Authenticate header, meaning the supplied 2FA code was rejected. The client records Using2FA and sets a retry prompt; the caller must re-authenticate with a fresh code.","triggerScenarios":"Thrown at pkg/ring/api.go:287 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-read the code from the authenticator/SMS and resubmit via GetAuth with the new twoFactorAuthCode","Check that the system clock is accurate for TOTP codes"],"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"}