diff --git a/dsh_sdk/examples/mqtt_token_fetcher.rs b/dsh_sdk/examples/mqtt_token_fetcher.rs index d1dc184..c94241c 100644 --- a/dsh_sdk/examples/mqtt_token_fetcher.rs +++ b/dsh_sdk/examples/mqtt_token_fetcher.rs @@ -8,7 +8,6 @@ async fn main() { let api_key = env::var("API_KEY").unwrap().to_string(); let mqtt_token_fetcher: MqttTokenFetcher = MqttTokenFetcher::new(tenant_name, api_key, None, dsh_sdk::Platform::NpLz) //Claims = None fetches all possible claims - .await .unwrap(); let token: MqttToken = mqtt_token_fetcher .get_token("Client-id", None) diff --git a/dsh_sdk/examples/mqtt_token_fetcher_specific_claims.rs b/dsh_sdk/examples/mqtt_token_fetcher_specific_claims.rs index 5b6ef9a..8a15359 100644 --- a/dsh_sdk/examples/mqtt_token_fetcher_specific_claims.rs +++ b/dsh_sdk/examples/mqtt_token_fetcher_specific_claims.rs @@ -22,7 +22,6 @@ async fn main() { Some(claims_vector), dsh_sdk::Platform::NpLz, ) - .await .unwrap(); let token: MqttToken = mqtt_token_fetcher diff --git a/dsh_sdk/src/mqtt_token_fetcher.rs b/dsh_sdk/src/mqtt_token_fetcher.rs index d87bf0f..927a47c 100644 --- a/dsh_sdk/src/mqtt_token_fetcher.rs +++ b/dsh_sdk/src/mqtt_token_fetcher.rs @@ -22,14 +22,14 @@ pub struct MqttTokenFetcher { } impl MqttTokenFetcher { - pub async fn new( + pub fn new( tenant_name: String, rest_api_key: String, claims: Option>, platform: Platform, //token_lifetime: Option, ) -> Result { - let rest_token = RestToken::get(&tenant_name, &rest_api_key, &platform).await?; + let rest_token = RestToken::default(); Ok(Self { tenant_name: tenant_name.clone(), rest_api_key: rest_api_key.clone(), @@ -330,6 +330,15 @@ impl RestToken { } } +impl Default for RestToken { + fn default() -> Self { + Self { + raw_token: "".to_string(), + exp: 0, + } + } +} + fn extract_header_and_payload(raw_token: &str) -> Result<&str, DshError> { let parts: Vec<&str> = raw_token.split('.').collect(); parts