tonhowtf/omniget · error

Falha ao obter guest token: HTTP

Error message

Falha ao obter guest token: HTTP {}

What it means

Thrown in get_guest_token when Twitter's guest token activation endpoint (api.twitter.com/1.1/guest/activate.json) responds with a non-2xx status. The library cannot proceed with guest-mode GraphQL queries without this token, so it fails with the HTTP status embedded in the message.

Solutions

  1. Verify the embedded public web Bearer token constant is current (Twitter rotates it)
  2. Retry after backoff — 429 means rate limited
  3. Route requests through a different IP/proxy if blocked
  4. Fall back to the syndication API path (request_syndication) which doesn't need a guest token

Example fix

// before
if !response.status().is_success() {
    return Err(anyhow!("Falha ao obter guest token: HTTP {}", response.status()));
}
// after
if response.status() == reqwest::StatusCode::TOO_MANY_REQUESTS {
    tokio::time::sleep(Duration::from_secs(30)).await;
    return self.get_guest_token().await; // retry once
}
if !response.status().is_success() {
    return Err(anyhow!("Falha ao obter guest token: HTTP {}", response.status()));
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: ensure Bearer token constant is non-empty and shaped like a JWT-ish token
fn bearer_looks_valid(t: &str) -> bool { t.starts_with("AAA") || t.len() > 100 }

Try / catch

match client.get_guest_token().await {
    Err(e) if e.to_string().contains("guest token") => {
        tokio::time::sleep(BACKOFF).await;
        client.get_guest_token().await // one retry, then fall back to syndication
    }
    other => other,
}

Prevention

When it happens

Trigger: The POST to activate.json fails: 401/403 due to invalid or missing public Bearer token, 429 rate-limited, 5xx from Twitter, or network middleware blocking the request.

Common situations: Twitter rotated/invalidated the public web Bearer token; heavy scraping hit rate limits; proxy/VPN IPs blocked by Twitter.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/platforms/twitter.rs:227

        if !force {
            let cached = self.guest_token.lock().await;
            if let Some(ref token) = *cached {
                return Ok(token.clone());
            }
        }

        let response = self
            .client
            .post(TOKEN_URL)
            .header("Authorization", BEARER)
            .header("x-twitter-client-language", "en")
            .header("x-twitter-active-user", "yes")
            .header("Accept-Language", "en")
            .send()
            .await?;

        if !response.status().is_success() {
            return Err(anyhow!(
                "Falha ao obter guest token: HTTP {}",
                response.status()
            ));
        }

        let json: serde_json::Value = response.json().await?;
        let token = json
            .get("guest_token")
            .and_then(|v| v.as_str())
            .ok_or_else(|| anyhow!("Guest token ausente na resposta"))?
            .to_string();

        let mut cached = self.guest_token.lock().await;
        *cached = Some(token.clone());
        Ok(token)
    }

    async fn request_tweet(

View on GitHub (pinned to 8600b91f42)