AlexxIT/go2rtc · error

2FA required

Error message

2FA required

What it means

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.

Solutions

  1. Collect the 2FA code (from PromptFor2FA) and call GetAuth again with twoFactorAuthCode
  2. Switch to refresh-token auth to avoid interactive 2FA
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/ring/api.go:300 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/dc0450e2343998a9. Report an issue: GitHub.

Appendix: source

Thrown at pkg/ring/api.go:300

		}

		c.Using2FA = true
		if resp.StatusCode == http.StatusBadRequest {
			c.PromptFor2FA = "Invalid 2fa code entered. Please try again."
			return nil, fmt.Errorf("invalid 2FA code")
		}

		if tfaResp.TSVState != "" {
			prompt := "from your authenticator app"
			if tfaResp.TSVState != "totp" {
				prompt = fmt.Sprintf("sent to %s via %s", tfaResp.Phone, tfaResp.TSVState)
			}
			c.PromptFor2FA = fmt.Sprintf("Please enter the code %s", prompt)
		} else {
			c.PromptFor2FA = "Please enter the code sent to your text/email"
		}

		return nil, fmt.Errorf("2FA required")
	}

	// Handle errors
	if resp.StatusCode != http.StatusOK {
		body, _ := io.ReadAll(resp.Body)
		return nil, fmt.Errorf("auth request failed with status %d: %s", resp.StatusCode, string(body))
	}

	var authResp AuthTokenResponse
	if err := json.NewDecoder(resp.Body).Decode(&authResp); err != nil {
		return nil, fmt.Errorf("failed to decode auth response: %w", err)
	}

	// Refresh token and expiry
	c.authToken = &authResp
	c.authConfig = &AuthConfig{
		RT:  authResp.RefreshToken,
		HID: c.hardwareID,

View on GitHub (pinned to c245815e75)