Forum Discussion
Hamish
Dec 16, 2009Cirrocumulus
Well.
The HTTP response that comes back will (Should, I tested this with my code and an incorrect password) be a 401 (Athentication required). I suspect if you're over-riding the authentication callbacks with browser basic auth, you'll probably get a second callback... Hold on... Maybe I can test that...
Yeah... OK, there will be more robsut methods of doing this, but we can take advantage of the fact that we can use the proxy() parameter to the SOAP initialisation to perform our default authentication, and if that fails, use the browser-basic response to try something else. You do this by having a function
----------------------------------------------------------------------------
Transport Information
----------------------------------------------------------------------------
sub SOAP::Transport::HTTP::Client::get_basic_credentials
{
print "SOAP::Transport::HTTP::Client::get_basic_credentials($icUser, $icPass)\n";
return "$icUser" => "$icPass";
}
in your code that over-rides the normal SOAP::Lite response to a 401 (Which is to give you an error). The initialisation call looks like this
my $userManagement = SOAP::Lite
-> uri('urn:iControl:System/ConfigSync')
-> proxy("$sProtocol://$icUser:$icPass\@$icServer:$icPort/iControl/iControlPortal.cgi");
Your auth callback will get called if the initial authentication fails.