The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(oauth): handle missing token_type in OAuth token response
Steven Enamakeladddd362af81
diff --git a/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs b/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rsindex 547f062076..958e099701 100644--- a/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs+++ b/crates/openhuman-tinyhumans/src/hosted/oauth/ops.rs@@ -12,7 +12,7 @@ use openhuman_core::config::Config;use openhuman_core::core::Outcome;use super::types::{IntegrationSummary, IntegrationTokensHandoff};-use crate::hosted::client::HostedClient;+use crate::hosted::client::{CredentialKind, HostedClient};const LOG_PREFIX: &str = "[hosted][oauth]";@@ -148,6 +148,44 @@ pub async fn oauth_revoke_integration())}+/// `POST /auth/integrations/{id}/client-key` — the one-time client key share+/// for an encrypted integration. The backend deletes it from temporary storage+/// once read.+///+/// The route has no typed SDK method and is absent from the backend's+/// published contract, so it rides the SDK's raw primitive (which still+/// applies the SDK's route policy). Session-only, as it always was: a+/// library-mode API key has no integrations to hand off.+pub async fn oauth_fetch_client_key(+ config: &Config,+ integration_id: &str,+) -> Result<Outcome<Value>, String> {+ let id = require_integration_id(integration_id)?;+ let client = HostedClient::from_config(config)?;+ if client.kind() != CredentialKind::Session {+ return Err("session JWT required".to_string());+ }+ let path = format!("/auth/integrations/{}/client-key", tinyhumans_sdk::enc(id));+ log::debug!("{LOG_PREFIX} fetching client key for integration {id}");+ let value = client.finish(+ "POST /auth/integrations/{integrationId}/client-key",+ client+ .sdk()+ .raw()+ .send(reqwest::Method::POST, &path, &[], None, true)+ .await,+ )?;+ let client_key = value+ .get("clientKey")+ .and_then(Value::as_str)+ .ok_or_else(|| "fetch client key: missing clientKey in response".to_string())?;+ log::debug!("{LOG_PREFIX} client key retrieved for integration {id}");+ Ok(Outcome::single_log(+ json!({ "clientKey": client_key, "integrationId": id }),+ "client key retrieved (one-time handoff)",+ ))+}+#[cfg(test)]#[path = "ops_tests.rs"]mod tests;diff --git a/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs b/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rsindex 51d2fafed3..74be5f3640 100644--- a/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs+++ b/crates/openhuman-tinyhumans/src/hosted/oauth/schemas.rs@@ -37,6 +37,7 @@ const FUNCTIONS: &[&str] = &["auth_oauth_list_integrations","auth_oauth_fetch_integration_tokens","auth_oauth_revoke_integration",+ "auth_oauth_fetch_client_key",];pub fn all_oauth_controller_schemas() -> Vec<ControllerSchema> {@@ -61,6 +62,10 @@ pub fn all_oauth_registered_controllers() -> Vec<RegisteredController> {schema: oauth_schemas("auth_oauth_revoke_integration"),handler: handle_auth_oauth_revoke_integration,},+ RegisteredController {+ schema: oauth_schemas("auth_oauth_fetch_client_key"),+ handler: handle_auth_oauth_fetch_client_key,+ },]}@@ -103,6 +108,16 @@ pub fn oauth_schemas(function: &str) -> ControllerSchema {inputs: vec![required_string("integrationId", "Integration id.")],outputs: vec![json_output("result", "Integration revoke result.")],},+ "auth_oauth_fetch_client_key" => ControllerSchema {+ namespace: "auth",+ function: "oauth_fetch_client_key",+ description: "Fetch one-time client key share for an encrypted OAuth integration.",+ inputs: vec![required_string(+ "integrationId",+ "Integration id (24-char hex).",+ )],+ outputs: vec![json_output("result", "Client key share payload (base64).")],+ },_ => ControllerSchema {namespace: "auth",function: "unknown",@@ -168,6 +183,17 @@ fn handle_auth_oauth_revoke_integration(params: Map<String, Value>) -> Controlle})}+fn handle_auth_oauth_fetch_client_key(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload = deserialize_params::<AuthOauthRevokeParams>(params)?;+ to_json(+ crate::hosted::oauth::oauth_fetch_client_key(&config, payload.integration_id.trim())+ .await?,+ )+ })+}+fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))}