Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, Does anyone have a working example of the LWP::UserAgent attribute of $ua->credentials($realm,$uname,$passwd) ? I tried with: $ua->credentials($url, $username, $password); but am still getting the error 407 proxy authentication required. Many thanks in advance!
  • Comment on Question on LWP::UserAgent attribute - $ua->credentials()

Replies are listed 'Best First'.
Re: Question on LWP::UserAgent attribute - $ua->credentials()
by marto (Archbishop) on Jul 05, 2006 at 11:04 UTC
    Anonymous Monk,

    Perhaps you could detail exactly what you are trying to do? It sounds as to you are behind a proxy and are trying to access a page which required user authentication. You may want to look at the Proxy attributes in the LWP::UserAgent documentation. If this is no help, please post the complete code you have, the error message (in full) and a better description of your circumstances (for example, are you behind a proxy server that requires a username and password before you can view webpages) and what you are trying to achieve. Also please read the PerlMonks FAQ and How do I post a question effectively? if you have not already done so.


      I have to agree, with marto here. You are saying you are getting a proxy error and you asking for help with credentials. Seems like two seperate issues. if you are positive that it is a credentials issues, here is a snippet that works for me,

      my $server = ''; my $port_no = 443; my $realm = 'Restricted Area'; # Make sure the text is an exact matc +h my $user = 'username'; my $passwd = 'password'; $ua->credentials( $server . $port_no, $realm, $user, $passwd );
Re: Question on LWP::UserAgent attribute - $ua->credentials()
by madtoperl (Friar) on Jul 05, 2006 at 12:08 UTC