Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: Semantic Types for Name-Strings Pin
BillWoodruff15-Feb-16 8:36
professionalBillWoodruff15-Feb-16 8:36 
GeneralRe: Semantic Types for Name-Strings Pin
Sascha Lefèvre15-Feb-16 9:08
professionalSascha Lefèvre15-Feb-16 9:08 
QuestionHow to reset scannersettings using .net code Pin
Member 1125820311-Feb-16 1:09
Member 1125820311-Feb-16 1:09 
AnswerRe: How to reset scannersettings using .net code Pin
OriginalGriff11-Feb-16 1:37
mveOriginalGriff11-Feb-16 1:37 
Questionavoid blinking screen+window form application c# Pin
ginsa vaheed10-Feb-16 23:31
ginsa vaheed10-Feb-16 23:31 
AnswerRe: avoid blinking screen+window form application c# Pin
Pete O'Hanlon10-Feb-16 23:34
mvePete O'Hanlon10-Feb-16 23:34 
AnswerRe: avoid blinking screen+window form application c# Pin
OriginalGriff11-Feb-16 0:34
mveOriginalGriff11-Feb-16 0:34 
AnswerRe: avoid blinking screen+window form application c# Pin
Richard MacCutchan11-Feb-16 1:35
mveRichard MacCutchan11-Feb-16 1:35 
AnswerRe: avoid blinking screen+window form application c# Pin
RugbyLeague11-Feb-16 3:38
RugbyLeague11-Feb-16 3:38 
AnswerRe: avoid blinking screen+window form application c# Pin
Gerry Schmitz11-Feb-16 5:04
mveGerry Schmitz11-Feb-16 5:04 
QuestionHow to implement class /component Versioning using abstract class in c# Pin
Tridip Bhattacharjee10-Feb-16 21:51
professionalTridip Bhattacharjee10-Feb-16 21:51 
AnswerRe: How to implement class /component Versioning using abstract class in c# Pin
Richard MacCutchan10-Feb-16 22:03
mveRichard MacCutchan10-Feb-16 22:03 
GeneralRe: How to implement class /component Versioning using abstract class in c# Pin
Tridip Bhattacharjee11-Feb-16 21:50
professionalTridip Bhattacharjee11-Feb-16 21:50 
GeneralRe: How to implement class /component Versioning using abstract class in c# Pin
Richard MacCutchan11-Feb-16 22:14
mveRichard MacCutchan11-Feb-16 22:14 
QuestionHow to red variable continuously Pin
Zefir110-Feb-16 20:34
Zefir110-Feb-16 20:34 
AnswerRe: How to red variable continuously Pin
OriginalGriff10-Feb-16 20:50
mveOriginalGriff10-Feb-16 20:50 
GeneralRe: How to red variable continuously Pin
Zefir110-Feb-16 21:20
Zefir110-Feb-16 21:20 
GeneralRe: How to red variable continuously Pin
OriginalGriff10-Feb-16 21:38
mveOriginalGriff10-Feb-16 21:38 
QuestionFTP vs SCP Pin
Kevin Marois10-Feb-16 7:42
professionalKevin Marois10-Feb-16 7:42 
AnswerRe: FTP vs SCP Pin
Richard Deeming10-Feb-16 10:11
mveRichard Deeming10-Feb-16 10:11 
GeneralRe: FTP vs SCP Pin
Kevin Marois10-Feb-16 10:29
professionalKevin Marois10-Feb-16 10:29 
GeneralRe: FTP vs SCP Pin
Eddy Vluggen10-Feb-16 10:41
professionalEddy Vluggen10-Feb-16 10:41 
QuestionBeginner on TCP Server/Client Implementation Pin
Member 1018338210-Feb-16 6:18
Member 1018338210-Feb-16 6:18 
QuestionProgrammatically login to website that uses 2 steps. Pin
Dralken10-Feb-16 2:18
Dralken10-Feb-16 2:18 
I'm working on making an app that scrapes my debit card account for my current balance and account activity. (I recently bought a Windows Phone, and they don't have an app for WP, and their website is not mobile friendly).

I'm running into an issue that has me a bit stumped. They use 2 steps for authentication. The first form submits the username and password, the 2nd asks for your date of birth as a secondary authentication.

I'm not sure where it's failing. I know the first request is good, as it brings up the DOB verify page, however after posting the DOB data, the 3rd response is back at the login screen.

The cookie headers are being filled, and all the response codes seem to be good. Does anyone see where the potential problem might be in this?

C#
HttpWebRequest http = WebRequest.Create(LoginURL) as HttpWebRequest;
http.KeepAlive = true;
http.Method = "POST";
http.ContentType = "application/x-www-form-urlencoded";
//http.CookieContainer = AuthCookies;
string postData = "languageCode=&reqType=&j_username=myuser&j_password=mypass&sign-in.x=29&sign-in.y=7";
byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http.ContentLength = postData.Length;

using (Stream postStream = http.GetRequestStream())
{
    postStream.Write(dataBytes, 0, dataBytes.Length);
}

HttpWebResponse httpResponse = http.GetResponse() as HttpWebResponse;
//foreach (Cookie ck in httpResponse.Cookies)
//{
//  AuthCookies.Add(ck);
//}
using (Stream respStream = httpResponse.GetResponseStream())
{
    StreamReader reader = new StreamReader(respStream, Encoding.UTF8);
    File.WriteAllText("loginresp.html", reader.ReadToEnd());
    reader.Close();
}

//DOB Verify
httpResponse.Close();
HttpWebRequest http2 = WebRequest.Create(DOBVerifyURL) as HttpWebRequest;
http2.KeepAlive = true;
http2.Method = "POST";
http2.ContentType = "application/x-www-form-urlencoded";
//http2.CookieContainer = AuthCookies;
http2.Headers["Cookie"] = httpResponse.Headers["Set-Cookie"];
http2.Referer = LoginURL;
http2.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36";
postData = "reqType=&cmd=checkSecu&languageCode=&additionalHolderAuthValue=urlencodeddob&continue.x=86&continue.y=13";
dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http2.ContentLength = postData.Length;
using (Stream postStream = http2.GetRequestStream())
{
    postStream.Write(dataBytes, 0, dataBytes.Length);
}
HttpWebResponse httpResponse2 = http2.GetResponse() as HttpWebResponse;
//foreach (Cookie ck in httpResponse2.Cookies)
//{
//  AuthCookies.Add(ck);
//}
using (Stream respStream2 = httpResponse2.GetResponseStream())
{
    HttpWebRequest http3 = WebRequest.Create(AcctActivityURL) as HttpWebRequest;
    http3.KeepAlive = true;
    http3.ContentType = "text/html";
    //http3.CookieContainer = AuthCookies;
    http3.Headers["Cookie"] = httpResponse2.Headers["Set-Cookie"];
    http3.Referer = LoginURL;
    http3.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36";
    http3.AllowAutoRedirect = false;
    HttpWebResponse httpResponse3 = http3.GetResponse() as HttpWebResponse;
    using (Stream respStream3 = httpResponse3.GetResponseStream())
    {
        StreamReader reader = new StreamReader(respStream3, Encoding.UTF8);
        File.WriteAllText("dobresp.html", reader.ReadToEnd());
        reader.Close();
    }
}

I copied the headers using Chrome's dev tools.
I can provide the working (from Chrome) headers, html, etc (edited of any personal info, of course) if needed.
(Side note: I don't plan on releasing or selling this app, this is purely for my own use. And it doesn't violate any terms or conditions so far as I can tell)
AnswerRe: Programmatically login to website that uses 2 steps. Pin
OriginalGriff10-Feb-16 4:14
mveOriginalGriff10-Feb-16 4:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.