Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

WWW::Mechanize authentication problem

by jclh (Initiate)
on Jun 03, 2013 at 00:04 UTC ( #1036634=perlquestion: print w/ replies, xml ) Need Help??
jclh has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm having a bit of frustration attempting to authenticate via mechanize... I'm trying to log in to ancestry.com with:
#!/usr/bin/perl -wd use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $response = $mech->get( "https://secure.ancestry.com/login" ); $mech->submit_form( form_number => 1, fields => { Username => 'MyUserName', Password => 'MyPassword', ReturnUrl => '' }, ); print $response->as_string( );

mech-dump https://secure.ancestry.com/login shows the form to look like this:

POST https://secure.ancestry.com/Login

Username= (text)

Password= (password)

ReturnUrl= (hidden readonly)

I think my confusion may be that I don't know what to do with the 'ReturnUrl' field so (I believe) I'm passing it back a null entry...

Anyway, each time I run it the server gives back a standard 'unknown user/pass' page...

I've double/triple checked my user/pass is correct.

Anyone have any ideas on this one?

Thank you!

JclH

Update

Thank you guys for the replies. Not sure which one, but one of the suggestions seems to have worked. Thanks!

Comment on WWW::Mechanize authentication problem
Download Code
Re: WWW::Mechanize authentication problem
by Anonymous Monk on Jun 03, 2013 at 05:08 UTC
    LOL, ditch $response, work with $mech
Re: WWW::Mechanize authentication problem
by runrig (Abbot) on Jun 03, 2013 at 17:09 UTC
    Is ReturnUrl filled in already? Don't include it in your list. I think it will default to the existing value in the form.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1036634]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-10-25 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls