public async Task getAuth(string user, string password) { SteamClient client = new SteamClient(); UserAuthenticator.CaptchaAnswer captchaAns = new UserAuthenticator.CaptchaAnswer(); if (!string.IsNullOrWhiteSpace(txtSteamguard.Text)) { SteamguardSolution = txtSteamguard.Text; } if (!string.IsNullOrWhiteSpace(txtCaptcha.Text)) { captchaAns.SolutionText = txtCaptcha.Text; } //Wanneer er geen steamguard en captcha wordt meegegeven. if (loginPhase == 0) { try { UserAuthenticator.SteamAccessRequestResult authId = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password)); if (authId.IsSteamGuardNeeded) { SteamguardID = authId.SteamGuardID; MessageBox.Show("Please fill in the steam code you received by mail."); txtSteamguard.Visibility = Visibility.Visible; lblSteamguard.Visibility = Visibility.Visible; loginPhase = 1; } if (authId.IsCaptchaNeeded) { CaptchaID = authId.CaptchaGID; MessageBox.Show("Please fill in the captcha code"); txtCaptcha.Visibility = Visibility.Visible; lblCaptcha.Visibility = Visibility.Visible; new BitmapImage(new Uri(authId.CaptchaURL.ToString())); loginPhase = 2; } MessageBox.Show(authId.User.AuthCookie.ToString()); } catch (SteamAuthenticationException) { MessageBox.Show("Incorrect login information"); } } //Wanneer er een steamguard wordt meegegeven if (loginPhase == 1) { UserAuthenticator.SteamGuardAnswer steamguardAns = new UserAuthenticator.SteamGuardAnswer(); steamguardAns.ID = SteamguardID; steamguardAns.SolutionText = SteamguardSolution; UserAuthenticator.SteamAccessRequestResult authId = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password, steamguardAns)); if (authId.IsSteamGuardNeeded) { SteamguardID = authId.SteamGuardID; MessageBox.Show("Please fill in the steam code you received by mail."); txtSteamguard.Visibility = Visibility.Visible; lblSteamguard.Visibility = Visibility.Visible; } if (authId.IsCaptchaNeeded) { CaptchaID = authId.CaptchaGID; MessageBox.Show("Please fill in the captcha code"); txtCaptcha.Visibility = Visibility.Visible; lblCaptcha.Visibility = Visibility.Visible; new BitmapImage(new Uri(authId.CaptchaURL.ToString())); } MessageBox.Show(authId.User.AuthCookie.ToString()); //UserAuthenticator s = UserAuthenticator.ForProtectedResource(authId.User); //client.Authenticator = s; //ISteamRequest request; //request.SteamApiMethod(SteamNews.GetNewsForAppAsync(client,4,4,4)); //MessageBox.Show(player.PersonaName.ToString()); } }
public async Task getInfo() { UserAuthenticator.SteamGuardAnswer sAnswer = new UserAuthenticator.SteamGuardAnswer(); UserAuthenticator.CaptchaAnswer cAnswer = new UserAuthenticator.CaptchaAnswer(); if (!string.IsNullOrWhiteSpace(txtSteamguard.Text)) { sAnswer.SolutionText = txtSteamguard.Text; } if (!string.IsNullOrWhiteSpace(txtCaptcha.Text)) { cAnswer.SolutionText = txtCaptcha.Text; } string captcha = txtCaptcha.Text; MessageBox.Show("fasiejfosfjois"); string user = txtUsername.Text; string password = txtPassword.Password; SteamUser swag = new SteamUser(); UserAuthenticator.SteamAccessRequestResult result = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password)); SteamguardID = result.SteamGuardID; if (result.IsCaptchaNeeded == true) { imgCaptcha.Source = new BitmapImage(new Uri(result.CaptchaURL.ToString())); MessageBox.Show("You received mail with captcha id"); } if (result.IsSteamGuardNeeded == true) { MessageBox.Show("You received mail with steamguard code"); } // MessageBox.Show("fasiejfosfjois"); // if (string.IsNullOrEmpty(txtCaptcha.Text) && !string.IsNullOrEmpty(txtSteamguard.Text)) //{ // SteamClient client = new SteamClient(); // string user = txtUsername.Text; // string password = txtPassword.Password; // SteamUser swag = new SteamUser(); // UserAuthenticator.SteamGuardAnswer realAnswer = new UserAuthenticator.SteamGuardAnswer(); // realAnswer.SolutionText = txtSteamguard.Text; // realAnswer.ID = SteamguardID; // UserAuthenticator.SteamAccessRequestResult result = await Task.Run(() => UserAuthenticator.GetAccessTokenForUserAsync(user, password,realAnswer)); // if (result.IsCaptchaNeeded == true) // { // imgCaptcha.Source = new BitmapImage(new Uri(result.CaptchaURL.ToString())); // MessageBox.Show("Check mail"); // } // if (result.IsSteamGuardNeeded == true) // { // MessageBox.Show("Check mail"); // } // SteamUser newUser = new SteamUser(); // newUser.SteamID = result.User.SteamID; // newUser.AuthCookie = result.User.AuthCookie; // newUser.TransferToken = result.User.TransferToken; // //SteamID newId = new SteamID(result.User.SteamID); // UserAuthenticator s = UserAuthenticator.ForProtectedResource(newUser.AuthCookie); // // SteamSharp.steam // //a/]][s.Authenticate(client,) // if(result.IsLoginComplete) // { // MessageBox.Show("Logged in as: " + newUser.SteamID + " auth token is :" + newUser.AuthCookie.Value.ToString()); // } // } }