{"record":{"id":"1f2ada9943464bd0","repo":"AlexxIT/go2rtc","slug":"failed-to-create-auth-request-w","errorCode":null,"errorMessage":"failed to create auth request: %w","messagePattern":"failed to create auth request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ring/api.go","lineNumber":606,"sourceCode":"\n\tvar grantData = map[string]string{\n\t\t\"grant_type\":    \"refresh_token\",\n\t\t\"refresh_token\": c.authConfig.RT,\n\t}\n\n\t// Add common fields\n\tgrantData[\"client_id\"] = \"ring_official_android\"\n\tgrantData[\"scope\"] = \"client\"\n\n\t// Make auth request\n\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","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/ring/api.go#L588-L624","documentation":"Returned when http.NewRequest fails while building the POST to Ring's OAuth token endpoint. In practice this happens only if the OAuth URL is malformed (unparseable URL), since the body is a valid bytes.Reader.","triggerScenarios":"oauthURL is empty, malformed, or contains invalid characters so http.NewRequest cannot parse it.","commonSituations":"Misconfigured base URL / OAuth endpoint override; empty config value substituted for the OAuth URL; environment-specific URL rewrites with bad characters.","solutions":["Check the wrapped error (url.Parse error) for the malformed URL detail","Verify the OAuth endpoint URL configuration (no empty or garbled value)","Ensure any base-URL override is a valid absolute http(s) URL"],"exampleFix":"// before\ncfg.OAuthURL = \"\" // yields unparsable request URL\n// after\ncfg.OAuthURL = \"https://oauth.ring.com/oauth/token\"","handlingStrategy":"validation","validationCode":"if u, err := url.Parse(oauthURL); err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid oauth url %q\", oauthURL)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure a valid absolute https:// OAuth URL","Validate any base-URL overrides with url.Parse before constructing the client","Never leave the OAuth endpoint config empty"],"tags":["http","url","oauth","ring"],"backgroundTag":"invalid-url","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"}