Note: vastly simplified.
package MyUA; use base 'LWP::UserAgent'; { my $user; my $pass; sub set_creds { $user = shift; $pass = shift; } sub get_basic_credentials { ($user, $pass) } }
get_basic_credentials() is called by the GET/POST/FOO methods when challenged (perhaps more often, you may need to verify this). I use it to read passwords from a config file, prompt from a terminal w/o echoing, and other times that I need to access restricted sites.
Update: credentials(), afaict, takes 4 parameters, not two. Perhaps that is the root of the reason it isn't working. Reached for my favorite hammer when a screwdriver was already provided.
Update 2: Per almut in Re^4: Better Solution To WWW::Mechanize Basic Authentication, I stand corrected. Two parameter version is quite correct.
--MidLifeXis
In reply to Re^3: Better Solution To WWW::Mechanize Basic Authentication
by MidLifeXis
in thread Better Solution To WWW::Mechanize Basic Authentication
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |