From 8680d8d4c0c30397570ba165283c84ad7452f010 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 25 Mar 2021 13:52:55 -0400 Subject: [PATCH] add oauth data parsing --- src/steamapi.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/steamapi.rs b/src/steamapi.rs index b359c35..fb9577c 100644 --- a/src/steamapi.rs +++ b/src/steamapi.rs @@ -202,11 +202,40 @@ impl UserLogin { return LoginResult::BadCredentials; } + let oauth: OAuthData = serde_json::from_str(login_resp.oauth).unwrap(); + let session = self.build_session(oauth); - return LoginResult::OtherFailure; + return LoginResult::Ok; + } + + fn build_session(&self, data: OAuthData) -> Session { + return Session{ + token: data.oauth_token, + steam_id: data.steamid, + steam_login: format!("{}%7C%7C{}", data.steamid, data.wgtoken), + steam_login_secure: format!("{}%7C%7C{}", data.steamid, data.wgtoken_secure), + session_id: todo!(), + web_cookie: todo!(), + }; } } +struct OAuthData { + oauth_token: String, + steamid: u64, + wgtoken: String, + wgtoken_secure: String, + webcookie: String, +} + +pub struct Session { + pub session_id: String, + pub steam_login: String, + pub steam_login_secure: String, + pub web_cookie: String, + pub token: String, + pub steam_id: u64, +} pub fn get_server_time() -> i64 { let client = reqwest::blocking::Client::new();