diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 11227ca..1522648 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -13,7 +13,7 @@ categories = ["cryptography", "api-bindings", "web-programming"] [dependencies] # HTTP and async runtime -reqwest = { version = "0.12", features = ["json", "stream"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls", "http2", "charset", "system-proxy"] } tokio = { version = "1.41", features = ["full"] } async-trait = "0.1" diff --git a/rust/src/client.rs b/rust/src/client.rs index 4faa00f..d0d0c52 100644 --- a/rust/src/client.rs +++ b/rust/src/client.rs @@ -30,7 +30,8 @@ impl OpenSecretClient { let base_url = base_url.into(); let use_mock = base_url.contains("localhost") || base_url.contains("127.0.0.1") - || base_url.contains("0.0.0.0"); + || base_url.contains("0.0.0.0") + || base_url.contains("10.0.2.2"); Ok(Self { client: Client::new(), @@ -45,7 +46,8 @@ impl OpenSecretClient { let base_url = base_url.into(); let use_mock = base_url.contains("localhost") || base_url.contains("127.0.0.1") - || base_url.contains("0.0.0.0"); + || base_url.contains("0.0.0.0") + || base_url.contains("10.0.2.2"); Ok(Self { client: Client::new(), @@ -806,6 +808,11 @@ impl OpenSecretClient { self.session_manager.get_refresh_token() } + pub fn set_tokens(&self, access_token: String, refresh_token: Option) -> Result<()> { + self.session_manager.clear_session()?; + self.session_manager.set_tokens(access_token, refresh_token) + } + // User Profile API pub async fn get_user(&self) -> Result { self.encrypted_api_call("/protected/user", "GET", None::<()>)