--- /dev/null
+#!/usr/bin/perl
+use strict; use warnings;
+
+use Digest::MD5 qw(md5_hex);
+use RPC::XML qw/smart_encode/;
+use RPC::XML::Client;
+use Data::Dumper; # for debugging
+
+die "usage: $0 <host> <barcode> <password>\n" unless $ARGV[2];
+
+# some example query params
+my $host = shift;
+my $barcode = shift;
+my $password = shift;
+
+$host = "http://$host/xml-rpc/";
+
+# --------------------------------------------------------------------
+# This sends an XML-RPC request and returns the RPC::XML::response
+# object.
+# $resp->value gives the Perl,
+# $resp->as_string gives the XML
+# --------------------------------------------------------------------
+sub request {
+ my( $service, $method, @args ) = @_;
+ my $connection = RPC::XML::Client->new("$host/$service");
+ my $resp = $connection->send_request($method, smart_encode(@args));
+ return $resp;
+}
+
+
+# --------------------------------------------------------------------
+# Login
+# --------------------------------------------------------------------
+sub login {
+ my( $barcode, $password ) = @_;
+
+ my $seed = request(
+ 'open-ils.auth',
+ 'open__ils.auth.authenticate.init', $barcode )->value;
+
+ die "No auth seed returned\n" unless $seed;
+
+ my $response = request(
+ 'open-ils.auth',
+ 'open__ils.auth.authenticate.complete',
+ {
+ barcode => $barcode,
+ password => md5_hex($seed . md5_hex($password)),
+ type => 'temp',
+ }
+ )->value;
+
+ die "No login response returned\n" unless $response;
+
+ my $key = $response->{payload}->{authtoken};
+
+ die "Login failed\n" unless $key;
+
+ return $key;
+}
+
+
+
+# --------------------------------------------------------------------
+# Login to the system so we can get an authentication token
+# --------------------------------------------------------------------
+my $authkey = login($barcode, $password);
+
+# --------------------------------------------------------------------
+# Retrieve the login session to get the user id
+# --------------------------------------------------------------------
+my $user = request(
+ 'open-ils.auth',
+ 'open__ils.auth.session.retrieve', $authkey);
+
+$user = $user->value->{__data__};
+
+# --------------------------------------------------------------------
+# Fetch the user again, this time "fleshed" with the addresses
+# --------------------------------------------------------------------
+my $fleshed_user = request(
+ 'open-ils.actor',
+ 'open__ils.actor.user.fleshed.retrieve',
+ $authkey, $user->{id}, ['billing_address','mailing_address']);
+
+$fleshed_user = $fleshed_user->value->{__data__};
+print Dumper($fleshed_user);
+
+