Another way to authenticate your client is to build a hex digest consisting of the user's password and a challenge as issued by the server. This is currently known as auth_method “challenge”.
Essentially, you generate a challenge by issuing a blank request to the getchallenge method. If your method call is successful you're given:
For your response, you then build a MD5 hex digest of the formula (challenge + MD5_hex(password)). To authenticate your client now, you simply send back the following 3 parameters, along with your username:
Example 9.2. Sample Perl script using getchallenge
use strict;
use Fcntl;
use XMLRPC::Lite;
use Data::Dumper;
use Digest::MD5 qw(md5_hex);
my $xmlrpc = new XMLRPC::Lite;
$xmlrpc->proxy("http://www.lj.com/interface/xmlrpc");
my $get_chal = xmlrpc_call("LJ.XMLRPC.getchallenge");
my $chal = $get_chal->{'challenge'};
my $user = "test";
my $pass = "pass";
print "chal: $chal\n";
my $response = md5_hex($chal . md5_hex($pass));
my $login = xmlrpc_call('LJ.XMLRPC.login', {
'username' => $user,
'auth_method' => 'challenge',
'auth_challenge' => $chal,
'auth_response' => $response,
});
print Dumper($login);
sub xmlrpc_call {
my ($method, $req) = @_;
my $res = $xmlrpc->call($method, $req);
if ($res->fault) {
print STDERR "Error:\n".
" String: " . $res->faultstring . "\n" .
" Code: " . $res->faultcode . "\n";
exit 1;
}
return $res->result;
}