Subject: | Generating invalid signature |
This may be a misunderstanding of the documentation rather than a bug,
but it seems to me that this should work:
#!/usr/bin/perl
use Net::OAuth;
use LWP::UserAgent;
$consumer_key = "7ee438dcff906a5dd9f8d47da2d4b302";
$consumer_secret = "50376257d668ed6e5a4185e6ef51bf9b";
$url = "https://identi.ca/api/statuses/update.json";
$token = "b75393878750a4b3db0703045947022f";
$token_secret = "76cec704d4f5baf24f2a58659bad05ae";
my $ua = LWP::UserAgent->new;
my $request = Net::OAuth->request("protected resource")->new(
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
request_url => $url,
request_method => 'GET',
signature_method => 'HMAC-SHA1',
timestamp => time,
nonce => int(rand(2 ** 32)),
token => $token,
token_secret => $token_secret,
extra_params => {status => $message},
);
$request->sign;
my $response = $ua->get($request->request_url,
Authorization => $request->to_authorization_header
);
print $response->code . ": " . $response->message . "\n";
Yet it doesn't. It isn't an identi.ca problem because I've also tried
the same code with Twitter with the same result, which is "401
Unauthorised". Identi.ca gives slightly more information, saying
"Invalid signature". (Of course, the secrets in the code above are made
up, but the ones I'm using are correct.)
I'm using Perl 5.10.1 and Net::OAuth 0.28 on Linux.