Subject: | Allow optional 'scope' parameter to get_request_token |
I needed to use the new permissions[1] functionality from LinkedIn in
conjunction with WWW::LinkedIn, the attached (trivial) patch implements
it.
It would be cool if this (or something similar) was rolled into the CPAN
distro.
Many thanks,
Scott
[1] https://developer.linkedin.com/blog/making-it-easier-you-develop-
linkedin
Subject: | add_scope_param.patch |
diff --git a/lib/WWW/LinkedIn.pm b/lib/WWW/LinkedIn.pm
index e66671a..af4339a 100644
--- a/lib/WWW/LinkedIn.pm
+++ b/lib/WWW/LinkedIn.pm
@@ -47,10 +47,12 @@ sub get_request_token
my $nonce = md5_hex(time() * rand());
my $timestamp = time();
+ my $request_url = 'https://api.linkedin.com/uas/oauth/requestToken';
+ $request_url .= '?scope=' . $args{scope} if $args{scope};
my $request = Net::OAuth->request("request token")->new(
consumer_key => $s->consumer_key,
consumer_secret => $s->consumer_secret,
- request_url => 'https://api.linkedin.com/uas/oauth/requestToken',
+ request_url => $request_url,
request_method => 'POST',
signature_method => 'HMAC-SHA1',
timestamp => $timestamp,
@@ -58,6 +60,7 @@ sub get_request_token
callback => $args{callback},
);
$request->sign;
+
my $res = LWP::UserAgent->new()->request(POST $request->to_url);
my ($token) = $res->content =~ m{token\=([^&]+)}
or confess "LinkedIn's API did not return a request token. Instead, it returned this:\n" . $res->as_string;