Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Net::OAuth and POST data

by Anonymous Monk
on Apr 14, 2015 at 22:46 UTC ( #1123459=note: print w/replies, xml ) Need Help??


in reply to Net::OAuth and POST data

what does your post request actually send ( $ua->add_handler("request_send", sub { shift->dump; return }); )?

The parameter POSTDATA looks suspicious, never seen that before in context of LWP::/HTTP::/Net:: , only in CGI.pm

Also, I'd switch to Net::OAuth::Simple its much less typing :)

Replies are listed 'Best First'.
Re^2: Net::OAuth and POST data
by gryphon (Abbot) on Apr 15, 2015 at 17:01 UTC

    Greetings,

    The POSTDATA is the XML content that's stored in $content. I tried Net::OAuth::Simple, but it turns out it really doesn't save all that much typing, honestly, and it doesn't solve my signing of POSTDATA problem.

      so what does your post request actually send ?

        Greetings,

        Take a look at the "Request Example" section of the API documentation. That request example is what I'm sending on the POST. However, the problem is that the POSTDATA is not getting signed by Net::OAuth, so the OAuth signature fails. I can construct the request just fine, but I can't seem to figure out how to give Net::OAuth the POSTDATA so it can sign the request properly.

Re^2: Net::OAuth and POST data
by Anonymous Monk on Sep 14, 2018 at 16:34 UTC
    my $req = HTTP::Request->new; my $ua = LWP::UserAgent->new; my %json; $json{apple} = "foo"; $json{kiwi} = "bar"; my $oauth = Net::OAuth->request('protected resource')->new( consumer_key => "...", consumer_secret => "......", token => ".....", token_secret => ".....", protocol_version => Net::OAuth::PROTOCOL_VERSION_1_0A, signature_method => "HMAC-SHA1", timestamp => time, nonce => int( rand( 2**32 ) ), request_url => ".....", request_method => "POST" ); $oauth->sign; $req->header('Authorization'=>$oauth->to_authorization_header.',realm= +"account"'); $req->content_type('application/json'); $req->header('accept' => 'application/json'); $req->method($oauth->request_method); $req->uri($oauth->request_url); $req->content(encode_json(\%json)); $ua->agent('Mozilla/8.0'); my $response=$ua->request($req);

    2018-09-15 Athanasius added code tags

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1123459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2020-11-23 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?