spclient: improve token request logging

This commit is contained in:
David Sheets 2023-12-01 16:40:00 +00:00
parent ba314b63e4
commit 29f3345030

View file

@ -270,7 +270,10 @@ impl SpClient {
match ClientTokenResponseType::from_i32(message.response_type.value()) { match ClientTokenResponseType::from_i32(message.response_type.value()) {
// depending on the platform, you're either given a token immediately // depending on the platform, you're either given a token immediately
// or are presented a hash cash challenge to solve first // 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) => { Some(ClientTokenResponseType::RESPONSE_CHALLENGES_RESPONSE) => {
debug!("Received a hash cash challenge, solving..."); debug!("Received a hash cash challenge, solving...");
@ -480,11 +483,14 @@ impl SpClient {
HeaderValue::from_str(&format!("{} {}", token.token_type, token.access_token,))?, HeaderValue::from_str(&format!("{} {}", token.token_type, token.access_token,))?,
); );
if let Ok(client_token) = self.client_token().await { match self.client_token().await {
headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?); Ok(client_token) => {
} else { let _ = headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?);
// currently these endpoints seem to work fine without it }
warn!("Unable to get client token. Trying to continue without..."); 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; last_response = self.session().http_client().request_body(request).await;