tonhowtf/omniget · error

informe o token e o ID da conta do Instagram

Error message

informe o token e o ID da conta do Instagram

What it means

publish_graph requires both an access token and an Instagram user ID in GraphAuth. Before any network call it trims both fields and, if either is empty, fails fast with "informe o token e o ID da conta do Instagram" (provide the token and the Instagram account ID). This is a required-input validation to avoid sending doomed requests to the Graph API.

Solutions

  1. Populate GraphAuth.access_token with a valid long-lived Instagram token before calling publish_graph
  2. Set GraphAuth.ig_user_id to the numeric ID of the Business/Creator Instagram account
  3. In the UI, gate the publish action on completed OAuth setup so empty credentials never reach the API

Example fix

// before
let auth = GraphAuth::default();
publish_graph(&auth, &req).await?; // Err: informe o token e o ID da conta do Instagram
// after
let auth = GraphAuth { access_token: load_token()?, ig_user_id: load_ig_user_id()? };
publish_graph(&auth, &req).await?;
Defensive patterns

Strategy: validation

Validate before calling

if auth.access_token.trim().is_empty() || auth.ig_user_id.trim().is_empty() {
    return Err("configure o token e o ID da conta do Instagram antes de publicar");
}

Type guard

fn has_graph_credentials(auth: &GraphAuth) -> bool {
    !auth.access_token.trim().is_empty() && !auth.ig_user_id.trim().is_empty()
}

Prevention

When it happens

Trigger: Calling publish_graph with a GraphAuth where access_token or ig_user_id is empty or whitespace-only — e.g. credentials not yet configured in the UI/settings store and defaults passed through.

Common situations: User never connected their Instagram account; settings saved before OAuth completed; config struct constructed with Default; migration lost stored credentials.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/instagram/publish.rs:603

            _ => tokio::time::sleep(std::time::Duration::from_secs(5)).await,
        }
    }
    Err(anyhow!("o Instagram demorou demais para processar a midia"))
}

/// Publica pela API oficial. `req.files` são URLs públicas.
pub async fn publish_graph(
    auth: &GraphAuth,
    req: &PublishRequest,
    progress: &super::super::ProgressFn,
    job: &str,
) -> anyhow::Result<PublishResult> {
    let id = format!("ig:{}", job);
    let http = super::super::client()?;
    let token = auth.access_token.trim().to_string();
    let user = auth.ig_user_id.trim().to_string();
    if token.is_empty() || user.is_empty() {
        return Err(anyhow!("informe o token e o ID da conta do Instagram"));
    }
    if req.files.is_empty() || !req.files.iter().all(|f| f.starts_with("http")) {
        return Err(anyhow!(
            "a API oficial so aceita URLs publicas (https://…) para os arquivos"
        ));
    }
    let media_url = format!("{}/{}/media", GRAPH, user);
    let is_video = |f: &str| {
        f.split('?')
            .next()
            .unwrap_or(f)
            .to_lowercase()
            .ends_with(".mp4")
            || f.to_lowercase().ends_with(".mov")
    };
    let creation_id = match req.kind.as_str() {
        "carousel" => {
            let total = req.files.len() as u64 + 2;

View on GitHub (pinned to 8600b91f42)