diff --git a/SteamAuth/SteamGuardAccount.cs b/SteamAuth/SteamGuardAccount.cs index 7101a3f..c0396c7 100644 --- a/SteamAuth/SteamGuardAccount.cs +++ b/SteamAuth/SteamGuardAccount.cs @@ -84,6 +84,17 @@ public async Task GenerateSteamGuardCodeAsync() { return GenerateSteamGuardCodeForTime(await TimeAligner.GetSteamTimeAsync()); } + + public async Task SignInViaQR(string idOfQR) { + var postBody = new NameValueCollection(); + postBody.Add("client_id", idOfQR); + postBody.Add("steamid", this.Session.SteamID.ToString()); + postBody.Add("code", GenerateSteamGuardCode()); + postBody.Add("code_type", "3"); + var response = await SteamWeb.POSTRequest("https://api.steampowered.com/IAuthenticationService/UpdateAuthSessionWithSteamGuardCode/v1/", null, postBody, "X-eresult"); + + return response == "1"; + } public string GenerateSteamGuardCodeForTime(long time) { diff --git a/SteamAuth/SteamWeb.cs b/SteamAuth/SteamWeb.cs index f769c26..b215f79 100644 --- a/SteamAuth/SteamWeb.cs +++ b/SteamAuth/SteamWeb.cs @@ -23,7 +23,7 @@ public static async Task GETRequest(string url, CookieContainer cookies) return response; } - public static async Task POSTRequest(string url, CookieContainer cookies, NameValueCollection body) + public static async Task POSTRequest(string url, CookieContainer cookies, NameValueCollection body, string headerName = null) { if (body == null) body = new NameValueCollection(); @@ -36,6 +36,11 @@ public static async Task POSTRequest(string url, CookieContainer cookies wc.Headers[HttpRequestHeader.UserAgent] = SteamWeb.MOBILE_APP_USER_AGENT; byte[] result = await wc.UploadValuesTaskAsync(new Uri(url), "POST", body); response = Encoding.UTF8.GetString(result); + + if (!string.IsNullOrEmpty(headerName) && wc.ResponseHeaders != null) + { + return wc.ResponseHeaders[headerName] ?? null; + } } return response; }