{"record":{"id":"38ebd9ac375bcaec","repo":"AlexxIT/go2rtc","slug":"auth-request-failed-w","errorCode":null,"errorMessage":"auth request failed: %w","messagePattern":"auth request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":617,"sourceCode":"\tbody, err := json.Marshal(grantData)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal auth request: %w\", err)\n\t}\n\n\treq, err := http.NewRequest(\"POST\", oauthURL, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create auth request: %w\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"hardware_id\", c.hardwareID)\n\treq.Header.Set(\"User-Agent\", \"android:com.ringapp\")\n\treq.Header.Set(\"2fa-support\", \"true\")\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"auth request failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == http.StatusPreconditionFailed {\n\t\treturn fmt.Errorf(\"2FA required. Please see documentation for handling 2FA\")\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn fmt.Errorf(\"auth request failed with status %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar authResp AuthTokenResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&authResp); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode auth response: %w\", err)\n\t}\n\n\t// Update auth config and refresh token","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L599-L635","documentation":"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.","triggerScenarios":"c.httpClient.Do(req) returns an error: DNS failure, connection refused/timeout, TLS error, proxy misconfiguration — any transport error on the OAuth POST.","commonSituations":"No internet or DNS outage; corporate proxy/firewall blocking oauth.ring.com; TLS interception with untrusted certs; IPv6 issues.","solutions":["Check the wrapped error for the underlying cause (DNS, timeout, TLS, refused)","Verify network connectivity and that the OAuth host is reachable (curl the token URL)","Configure HTTP_PROXY/HTTPS_PROXY correctly if behind a proxy","Add a custom http.Client with proper TLS/proxy settings if a corporate MITM is present"],"exampleFix":"// before\nclient := ring.NewClient(cfg) // default transport, corporate MITM fails\n// after\nclient.WithHTTPClient(&http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{RootCAs: corpPool}}})","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"oauth.ring.com:443\", 5*time.Second)\nif err != nil { /* network unreachable before auth attempt */ }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        // retry with backoff\n    }\n    // else: DNS/TLS/proxy problem, surface to user\n}","preventionTips":["Verify outbound 443 access to Ring's OAuth host from your environment","Configure HTTPS_PROXY where corporate egress requires it","Trust corporate MITM CAs via a custom http.Client transport","Add timeouts and bounded retries on the client transport"],"tags":["network","oauth","http-client","ring"],"backgroundTag":"network-request-failed","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"}