{"record":{"id":"c4b1bce57d091184","repo":"tonhowtf/omniget","slug":"n-o-achei-o-secuid-de-na-p-gina-do-perfil-a-sess-o-pode-ter","errorCode":null,"errorMessage":"não achei o secUid de @{} na página do perfil — a sessão pode ter expirado","messagePattern":"não achei o secUid de @(.+?) na página do perfil — a sessão pode ter expirado","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/tiktok/favorites.rs","lineNumber":370,"sourceCode":"    let session = opts\n        .session_netscape\n        .as_deref()\n        .filter(|c| !c.trim().is_empty())\n        .ok_or_else(|| {\n            anyhow!(\n                \"os favoritos e os curtidos só saem com a sua sessão: capture os cookies do \\\n                 tiktok.com pela extensão e escolha a conta aqui\"\n            )\n        })?;\n    let (client, _) = super::cookie_client(Some(session))?;\n\n    // O `secUid` vem da própria página do perfil, que só abre inteira para\n    // quem está logado.\n    pacer.wait().await;\n    let profile = format!(\"https://www.tiktok.com/@{}\", handle);\n    let html = client.get(&profile).send().await?.text().await?;\n    let sec_uid = parse_sec_uid(&html).ok_or_else(|| {\n        anyhow!(\n            \"não achei o secUid de @{} na página do perfil — a sessão pode ter expirado\",\n            handle\n        )\n    })?;\n\n    let mut out: Vec<Entry> = Vec::new();\n    let mut cursor = String::from(\"0\");\n    let teto = if opts.limit == 0 {\n        u32::MAX\n    } else {\n        opts.limit\n    };\n    for _ in 0..200 {\n        let url = item_list_url(&opts.source, &sec_uid, &cursor, 30)\n            .ok_or_else(|| anyhow!(\"fonte desconhecida: {}\", opts.source))?;\n        pacer.wait().await;\n        let resp = client.get(&url).header(\"Referer\", &profile).send().await?;\n        if !resp.status().is_success() {","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/tiktok/favorites.rs#L352-L388","documentation":"After authenticating with the session cookies, list_private() fetches the profile page HTML and extracts the secUid via parse_sec_uid; when extraction fails it raises this anyhow error. Since the full profile page only renders for logged-in sessions, a missing secUid usually means the session is no longer valid.","triggerScenarios":"Calling run for favorites/liked when the cookies are expired, the logged-in account was changed or logged out, TikTok served a consent/captcha page instead of the profile, or the handle does not exist so the page has no secUid.","commonSituations":"Cookies exported days/weeks ago have expired; user logged out or rotated devices; TikTok shows a login wall or bot check; handle typo makes the profile 404.","solutions":["Re-export fresh tiktok.com cookies (Netscape format) and update opts.session_netscape.","Verify the handle is correct and the profile opens in a browser while logged in with the same account.","Open tiktok.com in the browser; if it asks you to log in again or shows a captcha, resolve that before retrying.","Retry later if TikTok is serving a bot-check page; consider adding delay between runs."],"exampleFix":"// before\nlet opts = FavoritesOpts { session_netscape: Some(\"old-cookies.txt\".into()), .. };\n// after\n// re-export cookies.txt in the browser extension, then:\nlet opts = FavoritesOpts { session_netscape: Some(\"cookies-fresh.txt\".into()), .. };","handlingStrategy":"retry","validationCode":"// Rust\n// Verify session validity by opening the profile in the same cookie jar before batch runs:\n// if a browser with those cookies shows the login page, re-export cookies first.\nfn cookies_recent(path: &std::path::Path, max_age: std::time::Duration) -> bool {\n    std::fs::metadata(path).and_then(|m| m.modified()).ok()\n        .and_then(|t| t.elapsed().ok()).map_or(false, |age| age < max_age)\n}","typeGuard":"fn extracted_sec_uid(html: &str) -> Option<String> { parse_sec_uid(html) }","tryCatchPattern":"match run(opts).await {\n    Ok(entries) => render(entries),\n    Err(e) if e.to_string().contains(\"secUid\") => {\n        eprintln!(\"Sessão expirada — reexporte os cookies\");\n        // re-export then retry once\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Re-export cookies shortly before long scraping runs.","Verify the handle exists (profile opens in browser) before invoking.","Space out runs to avoid triggering TikTok's bot checks.","Handle re-login prompts in the browser before exporting cookies."],"tags":["tiktok","session-expired","authentication","scraping","rust"],"backgroundTag":"jwt-token-expired","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}