AlexxIT/go2rtc · error

err.Error()

Error message

err.Error()

What it means

GET /api/ring with email/password parameters creates a Ring REST client via ring.NewRestClient(ring.EmailAuth{...}, nil). If client construction fails, the handler returns HTTP 500 with the raw error. Construction validates the auth configuration and session setup, so failures mean the Ring client could not even be initialized before authentication was attempted.

Solutions

  1. Update go2rtc to the latest release so the bundled Ring library matches current Ring API behavior
  2. Verify outbound HTTPS access to Ring's API endpoints from the go2rtc host
  3. Double-check email/password query values for typos or missing URL-encoding
  4. Prefer the refresh_token flow, which is more stable across Ring auth changes

Example fix

// before
/api/ring?email=me@example.com&password=p@ss
// after (URL-encode special chars)
/api/ring?email=me@example.com&password=p%40ss
// or better: use a refresh token
/api/ring?refresh_token=<token>
Defensive patterns

Strategy: validation

Validate before calling

if email == "" || password == "" {
    return errors.New("both email and password query parameters are required")
}

Try / catch

resp, err := http.Get("http://server:1984/api/ring?email=...&password=...")
if resp.StatusCode == http.StatusInternalServerError {
    b, _ := io.ReadAll(resp.Body)
    return fmt.Errorf("ring client init failed: %s — update go2rtc or check network egress to Ring", b)
}

Prevention

When it happens

Trigger: Calling /api/ring?email=...&password=... where the underlying Ring session/client initialization errors (bad session state, network failure contacting Ring's auth endpoints, invalid auth configuration struct).

Common situations: Ring changing its authentication endpoints requiring a library update; network egress blocked to Ring's cloud API; empty/garbage password values; running an old go2rtc whose Ring library is outdated after Ring API changes.

Related errors


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

Appendix: source

Thrown at internal/ring/ring.go:40

func apiRing(w http.ResponseWriter, r *http.Request) {
	query := r.URL.Query()
	var ringAPI *ring.RingApi

	// Check auth method
	if email := query.Get("email"); email != "" {
		// Email/Password Flow
		password := query.Get("password")
		code := query.Get("code")

		var err error
		ringAPI, err = ring.NewRestClient(ring.EmailAuth{
			Email:    email,
			Password: password,
		}, nil)

		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		// Try authentication (this will trigger 2FA if needed)
		if _, err = ringAPI.GetAuth(code); err != nil {
			if ringAPI.Using2FA {
				// Return 2FA prompt
				api.ResponseJSON(w, map[string]interface{}{
					"needs_2fa": true,
					"prompt":    ringAPI.PromptFor2FA,
				})
				return
			}
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	} else if refreshToken := query.Get("refresh_token"); refreshToken != "" {
		// Refresh Token Flow

View on GitHub (pinned to c245815e75)