From 29f3345030b1ef998e6a1a198e5810d43ca9fe3e Mon Sep 17 00:00:00 2001 From: David Sheets Date: Fri, 1 Dec 2023 16:40:00 +0000 Subject: [PATCH] spclient: improve token request logging --- core/src/spclient.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/src/spclient.rs b/core/src/spclient.rs index 99e2c1c6..44c92ba6 100644 --- a/core/src/spclient.rs +++ b/core/src/spclient.rs @@ -270,7 +270,10 @@ impl SpClient { match ClientTokenResponseType::from_i32(message.response_type.value()) { // depending on the platform, you're either given a token immediately // or are presented a hash cash challenge to solve first - Some(ClientTokenResponseType::RESPONSE_GRANTED_TOKEN_RESPONSE) => break message, + Some(ClientTokenResponseType::RESPONSE_GRANTED_TOKEN_RESPONSE) => { + debug!("Received a granted token"); + break message; + } Some(ClientTokenResponseType::RESPONSE_CHALLENGES_RESPONSE) => { debug!("Received a hash cash challenge, solving..."); @@ -480,11 +483,14 @@ impl SpClient { HeaderValue::from_str(&format!("{} {}", token.token_type, token.access_token,))?, ); - if let Ok(client_token) = self.client_token().await { - headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?); - } else { - // currently these endpoints seem to work fine without it - warn!("Unable to get client token. Trying to continue without..."); + match self.client_token().await { + Ok(client_token) => { + let _ = headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?); + } + Err(e) => { + // currently these endpoints seem to work fine without it + warn!("Unable to get client token: {e} Trying to continue without...") + } } last_response = self.session().http_client().request_body(request).await;