Last active
August 29, 2015 14:21
-
-
Save tstachl/9cee3c2416029e6683b4 to your computer and use it in GitHub Desktop.
Calling the Desk.com API in perl using Net::OAuth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Net::OAuth 0.20; | |
use Data::Random qw(:all); | |
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A; | |
use HTTP::Request::Common; | |
use LWP::UserAgent; | |
my $ua = LWP::UserAgent->new; | |
my $request = Net::OAuth->request('protected resource')->new( | |
consumer_key => 'CONSUMER_KEY', | |
consumer_secret => 'CONSUMER_SECRET', | |
request_url => 'https://SUBDOMAIN.desk.com/api/v2/users/me', | |
request_method => 'GET', | |
signature_method => 'HMAC-SHA1', | |
timestamp => time, | |
nonce => join('', rand_chars(size=>16, set=>'alphanumeric')), | |
version => '1.0', | |
token => 'TOKEN', | |
token_secret => 'TOKEN_SECRET' | |
); | |
$request->sign; | |
my $res = $ua->request(GET $request->to_url); | |
print $res->content; |
@shardiwal did you change the subdomain as well, if your site has a cname + ssl please change the host.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It doesn't seems to authenticate user. regardless of adding consumer key, secret and token, token_secret.