http://www.perlmonks.org?node_id=67732


in reply to HTTP::Headers, HTTP::Request, Authentication, LWP::Useragent

I don't know if I am understanding completely, but it sounds like you need to provide a username and password for a site? If that is the case, LWP::UserAgent has the authorization_basic method that can be used something like this (directly from the lwpcook manpage):

Documents protected by basic authorization can easily be accessed like this:
use LWP::UserAgent; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => 'http://www.asite.com/'); $req->authorization_basic('myuid', 'mypassword'); print $ua->request($req)->as_string;

The other alternative is to provide a subclass of LWP::UserAgent that overrides the get_basic_credentials() method. Study the lwp-request program for an example of this.

Hope that helps.