Respective Monks,

I'm trying to login to a vendor web site in order to fetch some data, but their asp+ajax+jquery web site always prevent me from getting in, either via LWP or curl.
Here's how the web site is like:

1. The login page (www.xxxx.gov/pages/profile.aspx) expects me to enter my email address (which was used during registering). After hit 'submit' button, I should be brought to the 'login question verify' page.
2. On the verify page, I was expected to fill in an answer to the account verify question.
Then by hitting 'verify' button, I should get login and see the my account profile, while the cookie is also got.

Using firebug, I noticed every time I hit 'submit' or 'verify' button, it sent a 'GetUpdatedFormDigest' request in SOAP body, and then did the normal POST with the '__REQUESTDIGEST=<DigestValueReturned>' in content.

So, I used LWP to imitate the SOAP request and got a response with a Digest Value which seems reasonable.
Then I did the normal $ua->post() with this Digest Value and other form parameters I got from the very first login page.
I thought I had posted all the form parameters I could see in firebug (and HttpWatch); but every time, I can only get a respond with exactly same html page as the very first login page - which, was requesting the login email address again.

Here I paste the request headers that I caught from a successful login in the browser, with firebug:
1. Header of the SOAP request from the browser:

(Request-Line)    POST http://www.xxxxxxxxx.gov/_vti_bin/sites.asmx HTTP/1.1
Accept    */*
Accept-Encoding    gzip, deflate
Accept-Language    en-US,en;q=0.8
Content-Length    332
Content-Type    text/xml
Host    www.xxxxxxxxx.gov
Origin    http://www.xxxxxxxxx.gov
Pragma    no-cache
Proxy-Connection    Keep-Alive
Referer    http://www.xxxxxxxxx.gov/pages/profile.aspx
SOAPAction    http://schemas.microsoft.com/sharepoint/soap/GetUpdatedFormDigest
User-Agent    Mozilla/5.0 (Windows NT 6.1; WOW64; chromeframe/27.0.1453.94) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

   What I wrote in perl to produce this SOAP request:
133     $res = $ua->request(
134         POST "http://www.xxxxxxxxx.gov/_vti_bin/sites.asmx",
135         Content_Type => 'text/xml',
136         Referer      =>  'http://www.xxxxxxxxx.gov/pages/profile.aspx',
137         X-Requested-With => 'XMLHttpRequest',
138         Proxy-Connection =>  'Keep-Alive',
139         User-Agent   =>  'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
140         Content      => ${SOAP_BODY}
141     );

2. Header of the normal POST request from browser, which should be responded with the next html page:

(Request-Line)    POST http://www.xxxxxxxxx.gov/pages/profile.aspx HTTP/1.1
Accept    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding    gzip, deflate
Accept-Language    en-US,en;q=0.8
Content-Length    4570
Content-Type    application/x-www-form-urlencoded
Host    www.xxxxxxxxx.gov
Origin    http://www.xxxxxxxxx.gov
Pragma    no-cache
Proxy-Connection    Keep-Alive
Referer    http://www.xxxxxxxxx.gov/pages/profile.aspx
User-Agent    Mozilla/5.0 (Windows NT 6.1; WOW64; chromeframe/27.0.1453.94) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

   Again, what I wrote in my program to imitate this header:
148     my $header = HTTP::Headers->new(
149         'Accept'    =>  'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
150         'Accept-Encoding'=>'gzip, deflate',
151         'Proxy-Connection'=>  'Keep-Alive',
152         'Host'      =>  'www.xxxxxxxxx.gov',
153         'Referer'   =>  'http://www.xxxxxxxxx.gov/pages/profile.aspx',
154         'User-Agent'=>  'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
155         'Content-Type'=>'application/x-www-form-urlencoded',
156         'Origin'    =>  'http://www.xxxxxxxxx.gov',
157         'Accept-Language'=>'en-US,en;q=0.8',
158         'Pragma'    =>  'no-cache'
159         
160     );  
161     $ua->default_headers($header);


Dear Monks, could you let me know what I have missed in my praying that caused the vendor website shutting me out?

Thank you

In reply to Multiple Step Login in Perl by sylph001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.