tonhowtf/omniget · error · anyhow
o Trakt recusou o pedido de código
Error message
o Trakt recusou o pedido de código (HTTP {}) — confira o client_id What it means
Thrown by device_code() when the POST to https://api.trakt.tv/oauth/device/code returns a non-2xx status. Trakt rejected the code request, almost always because the supplied client_id is invalid, mistyped, or belongs to a deleted app.
Solutions
- Check the HTTP status in the message: 401/400 usually means bad client_id
- Re-copy the client_id from https://trakt.tv/oauth/applications and save it in the config
- Confirm the app still exists and is not deleted/revoked on Trakt
- Retry device_code() after fixing the credentials
Example fix
// before config.client_id = " <id with trailing space> "; // after config.client_id = config.client_id.trim(); save(config);
Defensive patterns
Strategy: try-catch
Validate before calling
if config.client_id.len() < 20 || config.client_id.contains(char::is_whitespace) {
return Err("client_id parece inválido — copie novamente do Trakt".into());
} Try / catch
match device_code().await {
Err(e) if e.to_string().contains("recusou o pedido") => {
// prompt user to re-enter client_id
}
other => other?,
} Prevention
- Trim credentials on save
- Verify the app still exists on trakt.tv/oauth/applications after any Trakt account changes
- Never swap client_id and client_secret fields
When it happens
Trigger: POST /oauth/device/code with a client_id that Trakt does not recognize — wrong value, extra whitespace, revoked/deleted app, or malformed config data.
Common situations: Copy-paste errors (trailing spaces, truncation), using the client_secret in the client_id field, deleting the Trakt app and recreating it (new credentials), typos in the config file.
Related errors
- informe primeiro o client_id da sua app do Trakt
- o device flow precisa do client_secret da sua app do Trakt
- o Trakt não devolveu o código do dispositivo
- other.message()
- Poll::Expired.message()
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/b6986a57134e3f53.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/lists/trakt.rs:246
/// Passo 1: pede o código que o usuário vai digitar em trakt.tv/activate.
pub async fn device_code() -> Result<DeviceCode> {
let c = {
let _g = LOCK.lock().unwrap_or_else(|e| e.into_inner());
load()
};
if c.client_id.is_empty() {
return Err(anyhow!(
"informe primeiro o client_id da sua app do Trakt (crie em {})",
APP_URL
));
}
let r = client()?
.post(format!("{}/oauth/device/code", AUTH))
.json(&serde_json::json!({ "client_id": c.client_id }))
.send()
.await?;
if !r.status().is_success() {
return Err(anyhow!(
"o Trakt recusou o pedido de código (HTTP {}) — confira o client_id",
r.status()
));
}
let v: Value = r.json().await?;
parse_device_code(&v)
}
pub fn parse_device_code(v: &Value) -> Result<DeviceCode> {
let s = |k: &str| {
v.get(k)
.and_then(|x| x.as_str())
.unwrap_or_default()
.to_string()
};
let n = |k: &str, d: u64| v.get(k).and_then(|x| x.as_u64()).unwrap_or(d);
let device = s("device_code");
let user = s("user_code");View on GitHub (pinned to 8600b91f42)