tonhowtf/omniget · error

Instagram redirecionou para login — post pode ser privado

Error message

Instagram redirecionou para login — post pode ser privado

What it means

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'.

Solutions

  1. Confirm the post is publicly viewable in an incognito browser.
  2. Supply authenticated cookies (sessionid etc.) in the request if the post is behind a private account.
  3. Use a residential IP or reduce request rate — datacenter IPs commonly get login-walled.
  4. Handle the error in the caller by reporting 'post requires authentication' to the user instead of retrying.

Example fix

// before
match platform.get_media_info(&url).await {
    Err(e) if e.to_string().contains("login") => { /* crash or generic retry */ }
    r => r?,
}
// after
match platform.get_media_info(&url).await {
    Err(e) if e.to_string().contains("login") => {
        println!("This post appears private; provide cookies or open it publicly.");
        return Ok(None);
    }
    r => r.map(Some)?,
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Preflight: does the post render publicly without login?
// GET https://www.instagram.com/p/<shortcode>/ and confirm HTML lacks a login form / contains og:title with the caption.

Try / catch

match platform.get_media_info(url).await {
    Err(e) if e.to_string().contains("login") => {
        // do NOT retry blindly; surface auth requirement
        Err(anyhow!("post requires authentication: provide session cookies or use a public post"))
    }
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/9bd525f6371b6f0b. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/platforms/instagram.rs:193

        let response = self
            .client
            .get(&url)
            .header(
                "Accept",
                "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            )
            .header("Accept-Language", "en-GB,en;q=0.9")
            .header("Sec-Fetch-Dest", "document")
            .header("Sec-Fetch-Mode", "navigate")
            .header("Sec-Fetch-Site", "none")
            .header("Sec-Fetch-User", "?1")
            .send()
            .await?;

        let html = response.text().await?;

        if Self::is_login_redirect(&html) {
            return Err(anyhow!(
                "Instagram redirecionou para login — post pode ser privado"
            ));
        }

        let csrf = Self::extract_object_entry("InstagramSecurityConfig", &html)
            .and_then(|v| {
                v.get("csrf_token")
                    .and_then(|t| t.as_str())
                    .map(|s| s.to_string())
            })
            .unwrap_or_default();

        let polaris = Self::extract_object_entry("PolarisSiteData", &html);
        let device_id = polaris
            .as_ref()
            .and_then(|v| {
                v.get("device_id")
                    .and_then(|t| t.as_str())

View on GitHub (pinned to 8600b91f42)