Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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 with:
#!/usr/bin/perl -wd use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $response = $mech->get( "" ); $mech->submit_form( form_number => 1, fields => { Username => 'MyUserName', Password => 'MyPassword', ReturnUrl => '' }, ); print $response->as_string( );

mech-dump shows the form to look like this:


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!



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
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2015-10-08 22:17 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (228 votes), past polls