AlexxIT/go2rtc · error

auth request failed with status

Error message

auth request failed with status %d: %s

What it means

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.

Solutions

  1. Check credentials and app user-agent assumptions
  2. Wait and retry if rate limited (429)
  3. Inspect the body for the specific OAuth error
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/ring/api.go:306 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/d37065d668b1c5f9. Report an issue: GitHub.

Appendix: source

Thrown at pkg/ring/api.go:306

		}

		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,
	}
	// Set token expiry (1 minute before actual expiry)
	expiresIn := time.Duration(authResp.ExpiresIn-60) * time.Second
	c.tokenExpiry = time.Now().Add(expiresIn)

	c.RefreshToken = encodeAuthConfig(c.authConfig)

View on GitHub (pinned to c245815e75)