AlexxIT/go2rtc · error

auth request failed

Error message

auth request failed: %w

What it means

Wrapped error from Ring OAuth: the HTTP POST of the grant request to the OAuth token URL itself failed at the transport level (network failure, timeout, DNS, or the connection was refused), before any status code was evaluated.

Solutions

  1. Check the wrapped error for the underlying cause (DNS, timeout, TLS, refused)
  2. Verify network connectivity and that the OAuth host is reachable (curl the token URL)
  3. Configure HTTP_PROXY/HTTPS_PROXY correctly if behind a proxy
  4. Add a custom http.Client with proper TLS/proxy settings if a corporate MITM is present

Example fix

// before
client := ring.NewClient(cfg) // default transport, corporate MITM fails
// after
client.WithHTTPClient(&http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{RootCAs: corpPool}}})
Defensive patterns

Strategy: retry

Validate before calling

conn, err := net.DialTimeout("tcp", "oauth.ring.com:443", 5*time.Second)
if err != nil { /* network unreachable before auth attempt */ }

Try / catch

if err != nil {
    var netErr net.Error
    if errors.As(err, &netErr) && netErr.Timeout() {
        // retry with backoff
    }
    // else: DNS/TLS/proxy problem, surface to user
}

Prevention

When it happens

Trigger: c.httpClient.Do(req) returns an error: DNS failure, connection refused/timeout, TLS error, proxy misconfiguration — any transport error on the OAuth POST.

Common situations: No internet or DNS outage; corporate proxy/firewall blocking oauth.ring.com; TLS interception with untrusted certs; IPv6 issues.

Related errors


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

Appendix: source

Thrown at pkg/ring/api.go:617

	body, err := json.Marshal(grantData)
	if err != nil {
		return fmt.Errorf("failed to marshal auth request: %w", err)
	}

	req, err := http.NewRequest("POST", oauthURL, bytes.NewReader(body))
	if err != nil {
		return fmt.Errorf("failed to create auth request: %w", err)
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept", "application/json")
	req.Header.Set("hardware_id", c.hardwareID)
	req.Header.Set("User-Agent", "android:com.ringapp")
	req.Header.Set("2fa-support", "true")

	resp, err := c.httpClient.Do(req)
	if err != nil {
		return fmt.Errorf("auth request failed: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode == http.StatusPreconditionFailed {
		return fmt.Errorf("2FA required. Please see documentation for handling 2FA")
	}

	if resp.StatusCode != http.StatusOK {
		body, _ := io.ReadAll(resp.Body)
		return 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 fmt.Errorf("failed to decode auth response: %w", err)
	}

	// Update auth config and refresh token

View on GitHub (pinned to c245815e75)