I am attempting to get a list of Google Apps contacts for a migration
tool written in Perl.  I have no problem processing a PUT request when
making a new contact, but when I'm trying to process a GET request for
a user I always get returned an "Authorization required" error.   This
is not a web application, and I'm using two-legged authentication as
an admin of my domain.
Here is how I'm creating the request, using Net::OAuth:


   my $url = "http://www.google.com/m8/feeds/contacts/$user_email/
full";
   my $time = time;
   my $nonce = md5_hex("nonce_key".$time);

   my $request = Net::OAuth->request('consumer')->new(
                        consumer_key => $consumer_key,
                        consumer_secret => $consumer_secret,
                        request_url => $url,
                        signature_method => 'HMAC-SHA1',
                        request_method => 'GET',
                        timestamp => $time,
                        nonce => $nonce,
                        extra_params =>  {
                                xoauth_requestor_id => $user_email,
                                'max-results' => 1000,
                        },
                       );
   $request->sign;
   my $lwp_request = GET $request->to_url;
   my $response = $lwp_object->request($lwp_request);



Here is code that does work, though, using a POST request.   very
similar process:

  my $cont_url = "http://www.google.com/m8/feeds/contacts/$user/full";;
  my $time = time;
  my $nonce = md5_hex("nonce_key".$time);
  my $oauth_request = Net::OAuth->request('consumer')->new(
          consumer_key => $consumer_key,
          consumer_secret => $consumer_secret,
          request_url => $cont_url,
          request_method=>'POST',
          signature_method => 'HMAC-SHA1',
          timestamp => $time,
          nonce => $nonce,
          extra_params =>  {
                 xoauth_requestor_id => $user,
          },
  );
  $oauth_request->sign;
  my $lwp_request = POST(
                      $oauth_request->to_url,
                      Content_Type => 'application/atom+xml',
                      Content => $xml,
                   );
  my $response = $lwp_object->request( $lwp_request );


Anyone see what I'm doing wrong?   I've never successfully done an
OAuth GET request.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts 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://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to