{"record":{"id":"ce62b0f0b78b0057","repo":"tinyhumansai/openhuman","slug":"login-token-is-required","errorCode":null,"errorMessage":"login token is required","messagePattern":"login token is required","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/api/rest.rs","lineNumber":516,"sourceCode":"        let state = value\n            .get(\"state\")\n            .and_then(Value::as_str)\n            .filter(|state| !state.is_empty())\n            .map(str::to_owned)\n            .context(\"missing state\")?;\n        Ok(ConnectResponse { oauth_url, state })\n    }\n\n    /// Fetches the current authenticated user profile using the provided JWT.\n    pub async fn fetch_current_user(&self, bearer_jwt: &str) -> Result<Value> {\n        self.authed_json(bearer_jwt, Method::GET, \"auth/me\", None)\n            .await\n    }\n\n    /// Exchanges a one-time login token (e.g. from Telegram) for a long-lived JWT.\n    pub async fn consume_login_token(&self, login_token: &str) -> Result<String> {\n        let token = login_token.trim();\n        anyhow::ensure!(!token.is_empty(), \"login token is required\");\n\n        // Backend serves `POST /auth/login-token/consume` with the token in a JSON\n        // body `{ token, audience? }` and returns `{ success, data: { jwt } }`\n        // (see backend `routes/auth.ts`). The legacy\n        // `telegram/login-tokens/{token}/consume` path-param route was removed, so\n        // the old call 404'd and Telegram/OAuth-token login could never complete\n        // (WIRING_GAPS_AUDIT C1/C2).\n        let response = self\n            .sdk\n            .auth()\n            .consume_login_token(&tinyhumans_sdk::api::types::LoginTokenRequest {\n                token: token.to_string(),\n            })\n            .await\n            .context(\"consume login token through TinyHumans SDK\")?;\n        let jwt = response\n            .get(\"jwt\")\n            .and_then(Value::as_str)","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/api/rest.rs#L498-L534","documentation":"consume_login_token exchanges a one-time login token for a JWT; the token argument is empty, so there is nothing to send to the backend and the exchange is refused client-side.","triggerScenarios":"Thrown at src/api/rest.rs:516 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the one-time login token received from the auth flow","Check for an empty or whitespace-only token before calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}