in reply to LWP::Credentials help with previously working perl script PLEASE???

This code works.

use LWP::UserAgent; my $url = "http://prism.library.cornell.edu/control/authBasic/authTest +/"; my ($servername) = $url =~ m!://([^/]+)!; my $port = 80; my $realm = 'User: test Pass:'; my $username = 'test'; my $password = 'this'; my $lwp = LWP::UserAgent->new( ); $lwp->cookie_jar( {} ); $lwp->credentials("$servername:$port", $realm, $username, $password); my $response = $lwp->get($url); print $response->as_string;

In your code you have:

my $url="$url"; my $req = $browser->get($url); <--- response object, not request obje +ct $req->authorization_basic($username, $password); <--- here is where yo +u pass your response object <--- generating the e +rror..... my $res = $browser->request($req); print $res->as_string;

Replies are listed 'Best First'.
Re^2: LWP::Credentials help with previously working perl script PLEASE???
by funeeldy (Initiate) on May 19, 2008 at 14:15 UTC
    Thank-you tachyon-II. I modified the code as you suggested. I am seeing a bit more debug which leads me to believe this is an ssl issue. Client-SSL-Warning: Peer certificate not verified Title: Access Denied Do you know how to code this so it works with ssl please?

      Different problem. In your example you are connecting to port 80 or vanilla HTTP. Now you are coming up with an SSL error. Perhaps the site is offering up an invalid certificate. Maybe you should be connecting to port 443. I have given you a perfectly functional example. I am not a mind reader, and have no intention to debug invisible code accessing an equally invisible site which is throwing an error that seems unlikely to be related to the code you have posted.