Maybe the Perl code will help diagnose. If anyone has written anything in
Perl to do secure AuthSub, please let me know. I didn't see anything that
looked right on CPAN.
sub callGoogleApi {
my ( $googleService, $googleUrl, $token ) = @_;
my $range = 999999999;
my $nonce = int(rand($range));
my $data_to_sign = 'GET ' . $googleUrl . ' ' . time() . ' ' . $nonce;
# open the private key file and read it into a string
my $keystring = '';
if ( open my $keyfilehandle, '<', "/path/to/myrsakey.pem" ) {
while (<$keyfilehandle>) {
$keystring .= $_;
}
close $keyfilehandle;
}
my $rsa = Crypt::OpenSSL::RSA->new_private_key($keystring);
$rsa->use_pkcs1_padding();
my $signature = $rsa->sign($data_to_sign);
#base64 encode the signature. Don't include a \n on the end.
my $encoded_sig = encode_base64($signature, '');
my $timeout_seconds = 40;
my $ua = LWP::UserAgent->new();
$ua->agent('Portal');
$ua->timeout( $timeout_seconds );
my $auth_header = 'AuthSub token="' . $token . '" ' . 'data="' .
$data_to_sign . '" ' . 'sig="' . $encoded_sig . '" ' . 'sigalg="rsa-sha1"';
my $req = HTTP::Request->new('GET', "$googleUrl", [ 'Authorization' =>
$auth_header ]);
my $response = $ua->request($req);
if ($response && $response->is_success) {
return $response->content;
}
elsif ($response) {
warn "[error] $googleService returned " . $response->status_line .
". Headers: " . $response->headers_as_string . " Content: " .
$response->content;
return '';
}
else {
warn "[error] $googleService returned undef; may have timed out";
return '';
}
}
--
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html