~nicohman/gogapi-rs

198182be0e4735abcecc1b39423fe5d6eebb4130 — nicohman 5 years ago a6ead7f login
Fix login crashing due to different clients
1 files changed, 16 insertions(+), 2 deletions(-)

M src/token.rs
M src/token.rs => src/token.rs +16 -2
@@ 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<cookie::Cookie> = normal_client
                let mut cookies_processed: Vec<cookie::Cookie> = client
                    .store
                    .get_request_cookies(&check_url)
                    .cloned()