Add some debug logging
continuous-integration/drone the build was successful Details

This commit is contained in:
Olivier 'reivilibre' 2021-11-13 08:00:26 +00:00
parent dbf2e24369
commit f77ccefd7c
1 changed files with 8 additions and 4 deletions

View File

@ -73,9 +73,10 @@ pub async fn monzo_client_freshened(
drop(state_inner);
let needs_refresh = exp_at_instant < SystemTime::now();
if needs_refresh {
eprintln!("Refreshing token.");
eprintln!("Refreshing token; expiry {:?}; now {:?}.", exp_at_instant, SystemTime::now());
eprintln!("DEBUG refresh_token being used {:?}", &refresh_token);
let client = reqwest::Client::new();
let auth_resp: MonzoAuthResponse = client
let resp = client
.post("https://api.monzo.com/oauth2/token")
.form(&[
("grant_type", "refresh_token"),
@ -84,9 +85,12 @@ pub async fn monzo_client_freshened(
("refresh_token", &refresh_token),
])
.send()
.await?
.json()
.await?;
eprintln!("DEBUG response status {:?}", resp.status());
let jv: serde_json::Value = resp.json()
.await?;
eprintln!("DEBUG raw JV {:#?}", jv);
let auth_resp: MonzoAuthResponse = serde_json::from_value(jv)?;
let mut state_inner = state.inner.write().await;
let monzo_state = state_inner.monzo_state.as_mut().unwrap();
monzo_state.access_token = auth_resp.access_token;