Re: LWP and Digest authentication
- From: earwigtc@xxxxxxxxx
- Date: 9 Feb 2007 08:39:50 -0800
I like it. I'm saving info (such as headers_as_string) of the request
object for debugging. I see $mech->response, but is there a way to
reference the request object? Never had to do it with just a
LWP::UserAgent object. Aside from that, I can rework using
WWW::Mechanize just fine.
I would still be interested in a working digest authentication example
with LWP directly, if anyone has one.
Earwig
On Feb 9, 7:42 am, Peter Scott <P...@xxxxxxxx> wrote:
On Thu, 08 Feb 2007 10:50:08 -0800, earwigtc wrote:
Hi all. I must be missing something here. Is LWP supposed to
automatically deal with digest authentication? I run the following
code (used often with basic auth) against a server requiring digest,
and continue to get 401s:
my $ua = new LWP::UserAgent;
my $h = HTTP::Headers->new();
$h->authorization_basic('user','password');
my $req = HTTP::Request->new('GET', 'http://the.website.com',
$h);
my $res = $ua->request($req);
I don't know what your problem is here or whether my suggestion will make
any difference, but I will point out that the new credentials() method I
added to WWW::Mechanize (1.20 and later) would make your code considerably
simpler:
my $mech = WWW::Mechanize->new;
$mech->credentials('user', 'password');
$mech->get('https://the.website.com/');
A sniff shows only one attempt to login, and no reaction to the fact
that the server returned a WWW-Authenticate header with the real,
nonce, etc. Do I need to call requests a different way to get the
auto-magical behavior? I'm using htis format because of other needs
(custom headers later).
You would be able to do this with $mech->add_header.
Since I can't find any discussion or example of digest instead of
basic, I figured it should work. Or do I need to do all the digest
legwork myself?
--
Peter Scotthttp://www.perlmedic.com/http://www.perldebugged.com/
.
- Follow-Ups:
- newbie PPM question
- From: Paul Mitchell
- Re: LWP and Digest authentication
- From: Peter Scott
- newbie PPM question
- References:
- LWP and Digest authentication
- From: earwigtc
- Re: LWP and Digest authentication
- From: Peter Scott
- LWP and Digest authentication
- Prev by Date: Re: LWP and Digest authentication
- Next by Date: Re: LWP and Digest authentication
- Previous by thread: Re: LWP and Digest authentication
- Next by thread: Re: LWP and Digest authentication
- Index(es):