in reply to Understanding oAuth with Perl

See https://www.yammer.com/api_oauth.html step 6

Basically, first time you run your app (perl program), it tells the user to start a browser and get some codes

Then the user runs the program again, but time provides the program with the codes he obtained (the program could keep running, waiting for the user, you write that part)

Net::OAuth::Simple tells you to see http://search.cpan.org/dist/Net-FireEagle/bin/fireeagle for a more complete example, also examples

Replies are listed 'Best First'.
Re^2: Understanding oAuth with Perl
by Gangabass (Vicar) on Mar 09, 2011 at 18:05 UTC
    Thank you for the reply. Now i have no problems with GET request but can't complete POSTs.
    if ($app->authorized) { my $response = $app->view_restricted_resource('https://www.yammer. +com/api/v1/users.xml' ); print $response->content."\n"; $response = $app->update_restricted_resource("https://www.yammer.c +om/api/v1/messages/", body => "Message body", broadcast => "true" ); print $response->content."\n"; exit; }
    I'll get error "POST on Net::OAuth::ProtectedResourceRequest=HASH(0x5590e74) failed: 302 Found". Can you explain why?
        After checking
        https://www.yammer.com/api_doc.html#resources_messages_manipulating
        When posting a new message, the response body will include the new message formatted as in message polling above. This allows you to immediately display the newly-posted message back to the user.
        I think its a bug that the api_doc doesn't explicitly list what type of status code the response should have, like it does for many other methods.

        I think you definitely need to check the content, maybe as per LWP::Debug?

        $app->{browser}->add_handler("response_done", sub { shift->dump; retur +n });

        Or maybe with

        ->SUPER::new( tokens => \%tokens, browser => WWW::Mechanize->new( autocheck => 0 ), )
        and then you can
        my $response = eval { $app->view_restricted_resource ... }; unless( $response ){ warn "ERROR $@ "; $response = $app->res; # WWW::Mechanize cache it for you } print $response->content;
        or something like that
      I got 401 Unauthorized response when I do POST. I have no issue with GET. Did you figure out your issue?