[Melbourne-pm] LWP and Digest authentication
cas at taz.net.au
Thu Nov 16 16:07:33 PST 2006
On Fri, Nov 17, 2006 at 10:09:13AM +1100, Guy Morton wrote:
> Anyone know of a good tutorial for this? I'm not having much luck so
see the lwptut man page for more details, but in summary it is like this:
my $browser = LWP::UserAgent->new;
'username' => 'password'
this should work for Basic and Digest auth.
(note that lwptut also mentions that neither authentication nor cookies
are available for LWP::Simple).
see also LWP::UserAgent which mentions this:
$ua->credentials( $netloc, $realm, $uname, $pass )
Set the user name and password to be used for a realm. It is
often more useful to specialize the get_basic_creden- tials()
(it's interesting that the username and password pair are a hash in the
lwptut example, and just members of a list in the man page. dunno which
is right, or if both are right)
$ua->get_basic_credentials( $realm, $uri, $isproxy )
This is called by request() to retrieve credentials for
documents by Basic or Digest Authentication. The arguments
passed in is the $realm provided by the server, the $uri and a
boolean flag to indicate if this is authentication against a
The method should return a username and password. It should
return empty list to abort the authentication resolu- tion
attempt. Subclasses can override this method to prompt the
for the information. An example of this can be found in
"lwp-request" program distributed with this library.
The base implementation simply checks a set of pre-stored
member, set up with the credentials() method.
hope that helps.
craig sanders <cas at taz.net.au> (part time cyborg)
More information about the Melbourne-pm