Skip to content

Commit 5029c4e

Browse files
committed
spclient: improve token request logging
1 parent da3b353 commit 5029c4e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

core/src/spclient.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ impl SpClient {
270270
match ClientTokenResponseType::from_i32(message.response_type.value()) {
271271
// depending on the platform, you're either given a token immediately
272272
// or are presented a hash cash challenge to solve first
273-
Some(ClientTokenResponseType::RESPONSE_GRANTED_TOKEN_RESPONSE) => break message,
273+
Some(ClientTokenResponseType::RESPONSE_GRANTED_TOKEN_RESPONSE) => {
274+
debug!("Received a granted token");
275+
break message;
276+
}
274277
Some(ClientTokenResponseType::RESPONSE_CHALLENGES_RESPONSE) => {
275278
debug!("Received a hash cash challenge, solving...");
276279

@@ -481,11 +484,14 @@ impl SpClient {
481484
HeaderValue::from_str(&format!("{} {}", token.token_type, token.access_token,))?,
482485
);
483486

484-
if let Ok(client_token) = self.client_token().await {
485-
headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?);
486-
} else {
487-
// currently these endpoints seem to work fine without it
488-
warn!("Unable to get client token. Trying to continue without...");
487+
match self.client_token().await {
488+
Ok(client_token) => {
489+
let _ = headers_mut.insert(CLIENT_TOKEN, HeaderValue::from_str(&client_token)?);
490+
}
491+
Err(e) => {
492+
// currently these endpoints seem to work fine without it
493+
warn!("Unable to get client token: {e} Trying to continue without...")
494+
}
489495
}
490496

491497
last_response = self.session().http_client().request_body(request).await;

0 commit comments

Comments
 (0)