From c17bdf92a593180fbf475e930f511aae7bcab601 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Mon, 9 Aug 2021 20:40:06 -0400 Subject: [PATCH] apply session id cookie if session is present to all requests --- steamguard/src/steamapi.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/steamguard/src/steamapi.rs b/steamguard/src/steamapi.rs index 9b3a894..6306265 100644 --- a/steamguard/src/steamapi.rs +++ b/steamguard/src/steamapi.rs @@ -179,24 +179,28 @@ impl SteamApiClient { } } - pub fn request(&self, method: reqwest::Method, url: U) -> RequestBuilder { + pub fn request(&self, method: reqwest::Method, url: U) -> RequestBuilder { + trace!("making request: {} {}", method, url); self.cookies .add_cookie_str("mobileClientVersion=0 (2.1.3)", &STEAM_COOKIE_URL); self.cookies .add_cookie_str("mobileClient=android", &STEAM_COOKIE_URL); self.cookies .add_cookie_str("Steam_Language=english", &STEAM_COOKIE_URL); + if let Some(session) = &self.session { + self.cookies.add_cookie_str(format!("sessionid={}", session.session_id).as_str(), &STEAM_COOKIE_URL); + } self.client .request(method, url) .header(COOKIE, self.cookies.cookies(&STEAM_COOKIE_URL).unwrap()) } - pub fn get(&self, url: U) -> RequestBuilder { + pub fn get(&self, url: U) -> RequestBuilder { self.request(reqwest::Method::GET, url) } - pub fn post(&self, url: U) -> RequestBuilder { + pub fn post(&self, url: U) -> RequestBuilder { self.request(reqwest::Method::POST, url) } @@ -298,6 +302,7 @@ impl SteamApiClient { } /// Endpoint: POST /steamguard/phoneajax + /// Requires `sessionid` cookie to be set. fn phoneajax(&self, op: &str, arg: &str) -> anyhow::Result { let mut params = hashmap! { "op" => op,