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

Hi,

How do I use LWP authentication if the realm is not predictable in advance? How do I get LWP to match realm by regular expression? Or retrieve the realm challenge from a failed-to-authenticate request?

Thanks!

Replies are listed 'Best First'.
Re: LWP authentication and realms
by ikegami (Patriarch) on Jun 28, 2010 at 03:10 UTC

    [$ua->get_basic_credentials( $realm, $uri, $isproxy )] is called by request() to retrieve credentials for documents protected by Basic or Digest Authentication. The arguments passed in is the $realm provided by the server, the $uri requested and a boolean flag to indicate if this is authentication against a proxy server.

    The method should return a username and password. It should return an empty list to abort the authentication resolution attempt. Subclasses can override this method to prompt the user for the information. An example of this can be found in lwp-request program distributed with this library.

    Emphasis mine.