I'm an idiot. my code wasn't properly formatting the email address. thanks for testing this code for me.
On Apr 2, 3:54 pm, Rex Roof <[email protected]> wrote: > it does! > thanks! > > now I'll go figure out what I was doing wrong. > > -Rex > > On Apr 2, 10:29 am, "Julian (Google)" <[email protected]> wrote: > > > Your code works like this: > > > #!/usr/bin/perl -w > > > use strict; > > use Getopt::Long; > > use HTTP::Request::Common "GET"; > > use LWP::UserAgent; > > use Digest::MD5 qw(md5 md5_hex md5_base64); > > use Net::OAuth; > > require 5.6.0; > > > my $lwp_object = LWP::UserAgent->new; > > > my $user_email = "[email protected]"; > > my $consumer_key = "domain.com"; > > my $consumer_secret = "gyEe..........."; > > 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); > > print $response->content; > > > On Apr 1, 8:49 pm, Rex Roof <[email protected]> wrote: > > > > heh, I don't even know why I would want to use V2 or not. I modified > > > my request to add the content-type header. > > > I think Net::OAuth is creating the Authorization header already. > > > This is still failing with the exact same error. > > > > Are there any examples of doing a GET request using perl and a 2- > > > legged OAuth? > > > > -Rex > > > > On Apr 1, 12:51 pm, "Julian (Google)" <[email protected]> wrote: > > > > > Hi, > > > > > I think you are missing the Content-Type and Authorization headers for > > > > the GET: > > > > > Content-Type: application/x-www-form-urlencoded > > > > Authorization: OAuth > > > > > If you want to use V2, you may also need the header: > > > > GData-Version: 2 > > > > > -Julian. > > > > > On Mar 31, 6:24 pm, Rex Roof <[email protected]> wrote: > > > > > > 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 -~----------~----~----~----~------~----~------~--~---
