From f77ccefd7cddadc17e39e50f61ce93b598a6ff26 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 13 Nov 2021 08:00:26 +0000 Subject: [PATCH] Add some debug logging --- src/monzo.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/monzo.rs b/src/monzo.rs index 598f60a..92ff40e 100644 --- a/src/monzo.rs +++ b/src/monzo.rs @@ -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;