public LoginResult GetAuthenticatorChallenge(bool sisi, out Token accessToken) { Windows.AuthenticatorChallengeWindow acw = new Windows.AuthenticatorChallengeWindow(this); acw.ShowDialog(); if (!acw.DialogResult.HasValue || !acw.DialogResult.Value) { SecurePassword = null; accessToken = null; return(LoginResult.InvalidAuthenticatorChallenge); } var uri = RequestResponse.GetAuthenticatorUri(sisi, state.ToString(), challengeHash); var req = RequestResponse.CreatePostRequest(uri, sisi, true, uri.ToString(), Cookies); using (SecureBytesWrapper body = new SecureBytesWrapper()) { body.Bytes = Encoding.ASCII.GetBytes(String.Format("Challenge={0}&RememberTwoFactor={1}&command={2}", Uri.EscapeDataString(acw.AuthenticatorCode), "true", "Continue")); req.ContentLength = body.Bytes.Length; try { using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(body.Bytes, 0, body.Bytes.Length); } } catch (System.Net.WebException e) { switch (e.Status) { case WebExceptionStatus.Timeout: { accessToken = null; return(LoginResult.Timeout); } default: throw; } } } LoginResult result = GetAccessToken(sisi, req, out accessToken); if (result == LoginResult.Success) { // successful authenticator challenge, make sure we save the cookies. App.Settings.Store(); } return(result); }