Re: LWP::UserAgent credentials netloc and realm



John Stumbles wrote:
Googling for how to get this to work I found that I'm not the only one to
have difficulties. I eventually found the answer at
http://groups-beta.google.com/group/comp.lang.perl.misc/browse_frm/thread/5cf8c33182974059/

Summary: you have to include the port no in the 'netloc' variable e.g.

Port no, no. Port number, yes. :-)

    credentials("http://abc.com:80";, "realm", "uname", "passwd");

The other thing that threw a lot of people, including me, was what exactly
'netloc' and 'realm' are. 'realm' is whatever the server is configured to
ask you e.g. "Enter username and password for foo at abc.com".


FYI:

The realm is only the "foo" part, in your example, and is typically (always?) displayed in the authentication window enclosed by double quotes.

Take a look at the server's response header. The realm information is returned as WWW-Authenticate. e.g.

WWW-Authenticate: Basic realm="realm info here"

The authentication window would then read:

Enter username and password for "realm info here" at my.host.com.


It would be nice to have this explained in the docs but as a 2nd best I hope this will come up closer to the top of a google search for anyone asking in future.
.