{"record":{"id":"9bd525f6371b6f0b","repo":"tonhowtf/omniget","slug":"instagram-redirecionou-para-login-post-pode-ser-privado","errorCode":null,"errorMessage":"Instagram redirecionou para login — post pode ser privado","messagePattern":"Instagram redirecionou para login — post pode ser privado","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/instagram.rs","lineNumber":193,"sourceCode":"        let response = self\n            .client\n            .get(&url)\n            .header(\n                \"Accept\",\n                \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n            )\n            .header(\"Accept-Language\", \"en-GB,en;q=0.9\")\n            .header(\"Sec-Fetch-Dest\", \"document\")\n            .header(\"Sec-Fetch-Mode\", \"navigate\")\n            .header(\"Sec-Fetch-Site\", \"none\")\n            .header(\"Sec-Fetch-User\", \"?1\")\n            .send()\n            .await?;\n\n        let html = response.text().await?;\n\n        if Self::is_login_redirect(&html) {\n            return Err(anyhow!(\n                \"Instagram redirecionou para login — post pode ser privado\"\n            ));\n        }\n\n        let csrf = Self::extract_object_entry(\"InstagramSecurityConfig\", &html)\n            .and_then(|v| {\n                v.get(\"csrf_token\")\n                    .and_then(|t| t.as_str())\n                    .map(|s| s.to_string())\n            })\n            .unwrap_or_default();\n\n        let polaris = Self::extract_object_entry(\"PolarisSiteData\", &html);\n        let device_id = polaris\n            .as_ref()\n            .and_then(|v| {\n                v.get(\"device_id\")\n                    .and_then(|t| t.as_str())","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/instagram.rs#L175-L211","documentation":"get_gql_params fetches the post's HTML page to extract GraphQL query parameters. When the returned HTML is detected as a login redirect (is_login_redirect), Instagram is not serving the public post page — most often because the post requires authentication — so the library fails with this Portuguese message meaning 'Instagram redirected to login — post may be private'.","triggerScenarios":"request_gql → get_gql_params fetches the post URL and is_login_redirect(&html) returns true: private account, login-walled post, logged-out access blocked, or Instagram serving an auth challenge to the client's IP/session.","commonSituations":"Scraping private or followers-only posts without cookies; datacenter IPs that Instagram forces into login walls; Instagram A/B tests pushing anonymous users to login; deleted posts that redirect to login.","solutions":["Confirm the post is publicly viewable in an incognito browser.","Supply authenticated cookies (sessionid etc.) in the request if the post is behind a private account.","Use a residential IP or reduce request rate — datacenter IPs commonly get login-walled.","Handle the error in the caller by reporting 'post requires authentication' to the user instead of retrying."],"exampleFix":"// before\nmatch platform.get_media_info(&url).await {\n    Err(e) if e.to_string().contains(\"login\") => { /* crash or generic retry */ }\n    r => r?,\n}\n// after\nmatch platform.get_media_info(&url).await {\n    Err(e) if e.to_string().contains(\"login\") => {\n        println!(\"This post appears private; provide cookies or open it publicly.\");\n        return Ok(None);\n    }\n    r => r.map(Some)?,\n}","handlingStrategy":"try-catch","validationCode":"// Preflight: does the post render publicly without login?\n// GET https://www.instagram.com/p/<shortcode>/ and confirm HTML lacks a login form / contains og:title with the caption.","typeGuard":null,"tryCatchPattern":"match platform.get_media_info(url).await {\n    Err(e) if e.to_string().contains(\"login\") => {\n        // do NOT retry blindly; surface auth requirement\n        Err(anyhow!(\"post requires authentication: provide session cookies or use a public post\"))\n    }\n    other => other,\n}","preventionTips":["Verify the post opens in an incognito browser before scraping.","Provide authenticated cookies for private accounts.","Avoid datacenter IPs; use residential egress and throttle request rate.","Detect login walls early (check for 'loginForm' in HTML) instead of parsing failures."],"tags":["instagram","authentication","scraping","rust"],"backgroundTag":"authentication-required","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}