jobro has asked for the wisdom of the Perl Monks concerning the following question:
hey perl monks, I am trying to login to a webmail server using the perl LWP::User Agent. This works well but before I can access the INBOX I am redirected back to the login page. Here is what I have so far:
use strict; use LWP; use LWP::Debug qw(+); my $url = 'https://www.a-university.edu/horde/imp/'; my $url_redi = $url . "redirect.php"; # there is a problem with the server's certificate, # but this is not the issue here my $ua = LWP::UserAgent->new( ssl_opts => { SSL_verify_mode => 'SSL_VERIFY_NONE'}); my $form = $ua->get($url_redi) or die "couldn't fetch $url_redi"; $form->is_success() or die $form->message(); # extract cookie my $formcont = $form->content(); my $sessionid; if ($formcont =~ m/Horde=(.*?)" method/s) { $sessionid = $1; } # submit user name and password # all other items required as shown by the web page source code my $response = $ua->post( $url . "?Horde=" . $sessionid, [ 'imapuser' => 'jobro', 'pass' => 'verysecret', 'actionID' => '105', 'url' => '', 'mailbox' => 'INBOX', 'server' => 'hardy.a-university.edu', 'port' => '143', 'namespace' => '', 'maildomain' => 'a-university.edu', 'protocol' => 'imap/notls', 'realm' => 'a-university.edu', 'folders' => 'mail/', 'new_lang' => 'en_US', 'button' => 'Log in' ] ); # at his point the # print $response->as_string(); # is as expected # now the server sends (as part of the http header) # a location for redirection # (I know that I can follow redirections automatically, but this # leads to the same problem) # so I read off the address and try to get this page my $inbox = $ua->get( $url . "mailbox.php?Horde=" . $sessionid, [ 'actionID' => '149', 'mailbox' => 'INBOX' ] ); # but now I am back to the login page :(
(I asked the same question on stack overflow, but no result)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl LWP::User Agent credentials ignored on redirect
by Corion (Patriarch) on Dec 20, 2015 at 10:08 UTC | |
by Anonymous Monk on Dec 20, 2015 at 10:33 UTC | |
|
Re: perl LWP::User Agent credentials ignored on redirect
by beech (Parson) on Dec 20, 2015 at 09:52 UTC |