tonhowtf/omniget · error · anyhow

conecte a conta do Trakt primeiro (o código aparece aqui e…

Error message

conecte a conta do Trakt primeiro (o código aparece aqui e você libera em trakt.tv/activate)

What it means

run() loads the stored Trakt credentials and, if access_token is empty, refuses to proceed because no OAuth session exists. The message tells the user to start the device-code flow: the code will appear in the app and must be activated at trakt.tv/activate.

Solutions

  1. Complete the Trakt device-code authentication in the app first (code appears in-app, activate at trakt.tv/activate)
  2. Verify the credentials file/store actually persisted the access token after auth
  3. Re-run the connect flow if the config was reset
  4. Check that the OAuth client_id is valid — a failed exchange can leave the token empty
Defensive patterns

Strategy: validation

Validate before calling

let c = trakt_config::load();
if c.access_token.is_empty() {
    // start device-code auth flow before calling run
    start_trakt_device_auth().await?;
}

Type guard

fn is_connected(c: &Credentials) -> bool { !c.access_token.is_empty() }

Try / catch

match trakt_lists::run(&opts, &progress).await {
    Err(e) if e.to_string().contains("conecte a conta") => {
        // trigger the in-app device-code connect flow (code + trakt.tv/activate)
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling run() before ever completing Trakt OAuth (credentials file has empty access_token), or after the stored config was reset/deleted.

Common situations: Fresh install with no account connected; config file corrupted or wiped; user connected a different tool that overwrote the credentials store; token never persisted after the device-code exchange.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/lists/trakt.rs:716

    pub username: String,
    pub entries: usize,
    pub by_part: Vec<super::letterboxd::PartCount>,
    pub requests: u32,
    pub files: Vec<String>,
    pub dest: String,
    pub sample: Vec<Entry>,
}

pub async fn run(opts: &Options, p: ProgressFn) -> Result<ExportResult> {
    if opts.dest.trim().is_empty() {
        return Err(anyhow!("escolha a pasta de destino"));
    }
    let mut c = {
        let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());
        load()
    };
    if c.access_token.is_empty() {
        return Err(anyhow!(
            "conecte a conta do Trakt primeiro (o código aparece aqui e você libera em trakt.tv/activate)"
        ));
    }
    refresh_if_needed(&mut c).await?;
    let api = Api::new(&c, opts.delay_ms)?;
    let want =
        |x: &str| opts.parts.is_empty() || opts.parts.iter().any(|s| s.eq_ignore_ascii_case(x));

    // Quem é o usuário — serve de teste de token e nomeia o arquivo.
    let mut username = c.username.clone();
    if let Ok((v, _)) = api.get_page("/users/settings", 1, 1).await {
        if let Some(u) = v
            .get("user")
            .and_then(|u| u.get("username"))
            .and_then(|x| x.as_str())
        {
            username = u.to_string();
            let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());

View on GitHub (pinned to 8600b91f42)