{"record":{"id":"19473b9c8c2b2bca","repo":"tonhowtf/omniget","slug":"informe-primeiro-o-client-id-da-sua-app-do-trakt-crie-em","errorCode":null,"errorMessage":"informe primeiro o client_id da sua app do Trakt (crie em {})","messagePattern":"informe primeiro o client_id da sua app do Trakt \\(crie em (.+?)\\)","errorType":"validation","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/lists/trakt.rs","lineNumber":235,"sourceCode":"            Poll::Expired => \"o código expirou antes de você liberar\",\n            Poll::Denied => \"acesso negado no site do Trakt\",\n            Poll::Http(_) => \"o Trakt respondeu algo inesperado\",\n        }\n    }\n}\n\nfn client() -> Result<reqwest::Client> {\n    crate::core::tools::client()\n}\n\n/// Passo 1: pede o código que o usuário vai digitar em trakt.tv/activate.\npub async fn device_code() -> Result<DeviceCode> {\n    let c = {\n        let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());\n        load()\n    };\n    if c.client_id.is_empty() {\n        return Err(anyhow!(\n            \"informe primeiro o client_id da sua app do Trakt (crie em {})\",\n            APP_URL\n        ));\n    }\n    let r = client()?\n        .post(format!(\"{}/oauth/device/code\", AUTH))\n        .json(&serde_json::json!({ \"client_id\": c.client_id }))\n        .send()\n        .await?;\n    if !r.status().is_success() {\n        return Err(anyhow!(\n            \"o Trakt recusou o pedido de código (HTTP {}) — confira o client_id\",\n            r.status()\n        ));\n    }\n    let v: Value = r.json().await?;\n    parse_device_code(&v)\n}","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/lists/trakt.rs#L217-L253","documentation":"Thrown by TraktLists::device_code before starting the OAuth device flow when the locally stored Trakt config has an empty client_id. The device-code endpoint requires the application's client_id to identify the registered Trakt app, so without it the flow cannot start. The message points to APP_URL (https://trakt.tv/oauth/applications) where the app is created.","triggerScenarios":"Calling device_code() before ever saving a Trakt config containing client_id, or after the config file exists but the client_id field was left blank/unwritten.","commonSituations":"Fresh install where the user connected no app yet; user created a Trakt app but only pasted the client_secret; a config migration/reset wiped the client_id field.","solutions":["Create an app at https://trakt.tv/oauth/applications and copy its client_id","Save the client_id into the tool's Trakt config (the same store read by load() under LOCK) before calling device_code()","Re-run device_code() after the config is populated"],"exampleFix":"// before\nconfig.client_secret = \"abc123\"; // client_id forgotten\nsave(config);\ndevice_code().await?;\n// after\nconfig.client_id = \"<trakt app client_id>\";\nconfig.client_secret = \"abc123\";\nsave(config);\ndevice_code().await?;","handlingStrategy":"validation","validationCode":"if config.client_id.trim().is_empty() {\n    return Err(\"configure o client_id do Trakt antes de conectar\".into());\n}","typeGuard":"fn has_client_id(c: &TraktConfig) -> bool { !c.client_id.trim().is_empty() }","tryCatchPattern":null,"preventionTips":["Store client_id and client_secret together at first setup","Validate config completeness before exposing the connect button","Trim whitespace when saving credential fields"],"tags":["oauth","trakt","config","device-flow"],"backgroundTag":"missing-required-config-field","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"}