{"record":{"id":"b16db27b7accad16","repo":"tonhowtf/omniget","slug":"conecte-a-conta-do-trakt-primeiro-o-c-digo-aparece-aqui-e","errorCode":null,"errorMessage":"conecte a conta do Trakt primeiro (o código aparece aqui e você libera em trakt.tv/activate)","messagePattern":"conecte a conta do Trakt primeiro \\(o código aparece aqui e você libera em trakt\\.tv/activate\\)","errorType":"validation","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/lists/trakt.rs","lineNumber":716,"sourceCode":"    pub username: String,\n    pub entries: usize,\n    pub by_part: Vec<super::letterboxd::PartCount>,\n    pub requests: u32,\n    pub files: Vec<String>,\n    pub dest: String,\n    pub sample: Vec<Entry>,\n}\n\npub async fn run(opts: &Options, p: ProgressFn) -> Result<ExportResult> {\n    if opts.dest.trim().is_empty() {\n        return Err(anyhow!(\"escolha a pasta de destino\"));\n    }\n    let mut c = {\n        let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());\n        load()\n    };\n    if c.access_token.is_empty() {\n        return Err(anyhow!(\n            \"conecte a conta do Trakt primeiro (o código aparece aqui e você libera em trakt.tv/activate)\"\n        ));\n    }\n    refresh_if_needed(&mut c).await?;\n    let api = Api::new(&c, opts.delay_ms)?;\n    let want =\n        |x: &str| opts.parts.is_empty() || opts.parts.iter().any(|s| s.eq_ignore_ascii_case(x));\n\n    // Quem é o usuário — serve de teste de token e nomeia o arquivo.\n    let mut username = c.username.clone();\n    if let Ok((v, _)) = api.get_page(\"/users/settings\", 1, 1).await {\n        if let Some(u) = v\n            .get(\"user\")\n            .and_then(|u| u.get(\"username\"))\n            .and_then(|x| x.as_str())\n        {\n            username = u.to_string();\n            let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/lists/trakt.rs#L698-L734","documentation":"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.","triggerScenarios":"Calling run() before ever completing Trakt OAuth (credentials file has empty access_token), or after the stored config was reset/deleted.","commonSituations":"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.","solutions":["Complete the Trakt device-code authentication in the app first (code appears in-app, activate at trakt.tv/activate)","Verify the credentials file/store actually persisted the access token after auth","Re-run the connect flow if the config was reset","Check that the OAuth client_id is valid — a failed exchange can leave the token empty"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let c = trakt_config::load();\nif c.access_token.is_empty() {\n    // start device-code auth flow before calling run\n    start_trakt_device_auth().await?;\n}","typeGuard":"fn is_connected(c: &Credentials) -> bool { !c.access_token.is_empty() }","tryCatchPattern":"match trakt_lists::run(&opts, &progress).await {\n    Err(e) if e.to_string().contains(\"conecte a conta\") => {\n        // trigger the in-app device-code connect flow (code + trakt.tv/activate)\n    }\n    other => other?,\n}","preventionTips":["Run the device-code connect flow as onboarding before any export","Verify access_token persisted to the config store after auth","Detect expired/empty tokens at app startup and prompt reconnection"],"tags":["trakt","oauth","authentication-required","device-code"],"backgroundTag":"authentication-required","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}