{"record":{"id":"26929681cff45c79","repo":"tonhowtf/omniget","slug":"informe-o-token-de-acesso-e-o-id-de-usuario-do-painel","errorCode":null,"errorMessage":"informe o token de acesso e o ID de usuario do painel","messagePattern":"informe o token de acesso e o ID de usuario do painel","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ai_keys.rs","lineNumber":477,"sourceCode":"            let j: serde_json::Value = c\n                .get(format!(\"{}/user/info\", entry.base_url))\n                .bearer_auth(&entry.key)\n                .send()\n                .await?\n                .error_for_status()?\n                .json()\n                .await?;\n            format!(\n                \"{} CNY\",\n                j[\"data\"][\"balance\"]\n                    .as_str()\n                    .or_else(|| j[\"data\"][\"totalBalance\"].as_str())\n                    .unwrap_or(\"?\")\n            )\n        }\n        \"newapi\" => {\n            if entry.access_token.is_empty() {\n                return Err(anyhow!(\n                    \"informe o token de acesso e o ID de usuario do painel\"\n                ));\n            }\n            let j: serde_json::Value = c\n                .get(format!(\"{}/api/user/self\", site_of(&entry.base_url)))\n                .bearer_auth(&entry.access_token)\n                .header(\"New-Api-User\", &entry.user_id)\n                .send()\n                .await?\n                .error_for_status()?\n                .json()\n                .await?;\n            if j[\"success\"].as_bool() == Some(false) {\n                return Err(anyhow!(\n                    \"{}\",\n                    j[\"message\"].as_str().unwrap_or(\"painel recusou\")\n                ));\n            }","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ai_keys.rs#L459-L495","documentation":"The balance() function supports several provider kinds; for the 'newapi' kind it requires both an access token and a user ID from the panel. If the key entry's access_token field is empty, it throws this Portuguese-language error telling the user to provide the panel's access token and user ID.","triggerScenarios":"Calling balance(id) on a key entry whose provider is classified as 'newapi' but whose access_token field was never filled in (only the API key was stored).","commonSituations":"NewAPI/one-api style panels need token + user ID for the /api/user/self balance endpoint; users often save only the sk- API key and omit the panel access token and numeric user ID.","solutions":["Edit the key entry and fill in the access token (from the panel's token page) and the user ID (shown in the panel profile).","Save the entry and re-run the balance check.","If the panel exposes an API-key-based balance route instead, set the provider kind to one that uses the API key rather than 'newapi'."],"exampleFix":"// before\nentry.access_token = \"\"                        // balance() fails\n// after\nentry.access_token = \"eyJhbGciOi...\";          // panel access token\nentry.user_id = Some(\"42\");                    // panel user ID","handlingStrategy":"validation","validationCode":"// guard before calling balance()\nlet entry = get(id)?;\nif entry.access_token.is_empty() {\n    eprintln!(\"newapi panels need access_token AND user id from the panel\");\n}","typeGuard":"fn can_query_balance(e: &KeyEntry) -> bool { !e.access_token.is_empty() }","tryCatchPattern":"match balance(id) {\n    Ok(text) => show(text),\n    Err(e) if e.to_string().contains(\"informe o token de acesso\") => open_panel_credentials_form(),\n    Err(e) => show_error(e),\n}","preventionTips":["Collect access token and user ID when adding newapi/one-api panel keys","Link users to the panel's token page in your onboarding UI","Validate required fields at entry save time, not at query time","Distinguish API keys from panel access tokens in the data model"],"tags":["configuration","missing-credentials","api"],"backgroundTag":"missing-credentials","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"}