Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SteamAuth/SteamGuardAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ public async Task<string> GenerateSteamGuardCodeAsync()
{
return GenerateSteamGuardCodeForTime(await TimeAligner.GetSteamTimeAsync());
}

public async Task<bool> 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)
{
Expand Down
7 changes: 6 additions & 1 deletion SteamAuth/SteamWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task<string> GETRequest(string url, CookieContainer cookies)
return response;
}

public static async Task<string> POSTRequest(string url, CookieContainer cookies, NameValueCollection body)
public static async Task<string> POSTRequest(string url, CookieContainer cookies, NameValueCollection body, string headerName = null)
{
if (body == null)
body = new NameValueCollection();
Expand All @@ -36,6 +36,11 @@ public static async Task<string> 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;
}
Expand Down