From 198182be0e4735abcecc1b39423fe5d6eebb4130 Mon Sep 17 00:00:00 2001 From: nicohman Date: Mon, 18 Mar 2019 18:54:25 -0700 Subject: [PATCH] Fix login crashing due to different clients --- src/token.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/token.rs b/src/token.rs index 9ab7b2e..ce0498a 100644 --- a/src/token.rs +++ b/src/token.rs @@ -93,7 +93,21 @@ impl Token { let auth_url = captures[1].to_string(); println!("Auth URl: {}", auth_url); info!("Got URL, requesting auth page"); - let mut aresult = normal_client.get(&auth_url).map_err(convert_rsession)?; + let mut aresult = client.get(&auth_url).map_err(convert_rsession)?; + while aresult.status().is_redirection() { + println!("Redirect!"); + let mut next_url = aresult + .headers() + .get("Location") + .unwrap() + .to_str() + .unwrap() + .to_string(); + println!("{:?}", aresult); + aresult = client + .get(reqwest::Url::parse(&next_url).unwrap()) + .map_err(convert_rsession)? + } println!("{:?}", aresult); info!("Auth page request successful"); let atext = aresult.text().expect("Couldn't get auth page text"); @@ -127,7 +141,7 @@ impl Token { .client .post_request(&check_url) .form(&form_parameters); - let mut cookies_processed: Vec = normal_client + let mut cookies_processed: Vec = client .store .get_request_cookies(&check_url) .cloned() -- 2.45.2