tonhowtf/omniget · error
{}
Error message
{} What it means
After fetching the newapi panel's /api/user/self endpoint, balance() checks the JSON's success flag; if it is explicitly false it throws the panel's own message (or the fallback 'painel recusou'). This surfaces panel-side rejections such as invalid token, wrong user ID, or suspended accounts, wrapped via anyhow!("{}", ...).
Solutions
- Read the embedded panel message (j.message) for the specific rejection reason.
- Regenerate the access token in the panel and update the key entry.
- Confirm the user ID stored in the entry matches the token's account.
- Check account standing with the panel administrator (suspension/quota bans cause refusals).
Example fix
// before
{ success: false, message: "无权进行此操作,未登录或未登录已过期" }
// after: refresh token in panel, then
entry.access_token = "<newly generated token>"; Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate panel credentials via the same endpoint
let j: serde_json::Value = client
.get(format!("{base}/api/user/self"))
.bearer_auth(&access_token)
.send().await?.json().await?;
if j["success"].as_bool() == Some(false) {
eprintln!("panel refused: {}", j["message"].as_str().unwrap_or("?"));
} Type guard
fn panel_accepted(j: &serde_json::Value) -> bool { j["success"].as_bool() != Some(false) } Try / catch
match balance(id) {
Ok(text) => show(text),
Err(e) if e.to_string().contains("painel recusou") || /* panel message */ true => {
if is_auth_related(&e.to_string()) { prompt_token_refresh(); } else { show_error(e); }
}
Err(e) => show_error(e),
} Prevention
- Regenerate panel access tokens when sessions expire
- Keep user ID in sync with the token's account
- Surface the panel's own message to the user instead of generic errors
- Check account standing with panel admins for repeated refusals
When it happens
Trigger: Calling balance(id) for a 'newapi' entry where the panel responds {success:false,message:...}: expired access token, mismatched user ID, banned/deactivated account, or insufficient permission for the API route.
Common situations: Panel sessions/tokens expire and users keep querying balance with stale tokens; user ID changed after re-registration; panel admin disabled API access.
Related errors
- Anthropic
- Gemini
- a sessão do Goodreads não está válida: capture os cookies…
- a sessão do Medium não listou nenhuma história sua (a…
- acesso negado (HTTP ). Capture os cookies da sua conta no…
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/da98d971beb2f943.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/ai_keys.rs:491
)
}
"newapi" => {
if entry.access_token.is_empty() {
return Err(anyhow!(
"informe o token de acesso e o ID de usuario do painel"
));
}
let j: serde_json::Value = c
.get(format!("{}/api/user/self", site_of(&entry.base_url)))
.bearer_auth(&entry.access_token)
.header("New-Api-User", &entry.user_id)
.send()
.await?
.error_for_status()?
.json()
.await?;
if j["success"].as_bool() == Some(false) {
return Err(anyhow!(
"{}",
j["message"].as_str().unwrap_or("painel recusou")
));
}
let d = &j["data"];
let quota = d["quota"].as_f64().unwrap_or(0.0) / 500_000.0;
let used = d["used_quota"].as_f64().unwrap_or(0.0) / 500_000.0;
format!("{} ({} usados)", usd(quota), usd(used))
}
_ => return Err(anyhow!("este provedor nao expoe saldo pela API")),
};
update(id, |e| e.balance = Some(text))
}
// ── Exportar ───────────────────────────────────────────────────────────
fn is_openai_compatible(kind: &str) -> bool {
!matches!(kind, "anthropic" | "gemini")View on GitHub (pinned to 8600b91f42)