Having some problems trying to exchange my JSAPI tokens for REST Oauth Tokens (https://developer.linkedin.com/documents/exchange-jsapi-tokens-rest-api-oauth-tokens)
I'm using this library - http://code.google.com/p/oauth-php/ - As opposed to the PECL extension as I'm unable to install extensions onto the server.
There seem to be plenty of similar questions, but none which actually answer the question - How to use the above library to authenticate with Linkedin.
My code is as follows:
$cookie_name = "linkedin_oauth_" . $this->_c->linkedin_api_key;
$credentials_json = stripslashes($_COOKIE[$cookie_name]);
$credentials = json_decode($credentials_json);
// Get the Access Token + Secret
$access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken';
OAuthStore::instance("2Leg", array(
'consumer_key' => $this->_c->linkedin_api_key,
'consumer_secret' => $this->_c->linkedin_api_secret
));
try {
$request = new OAuthRequester($access_token_url, 'POST', array(
'xoauth_oauth2_access_token' => $credentials->access_token
));
$result = $request->doRequest();
} catch(OAuthException2 $e) {
print_r($e->getMessage());
}
The catch statement outputs:
Request failed with code 400: oauth_problem=parameter_absent&oauth_parameters_absent=oauth_verifier
How do I get this oauth_verifier? It was my understanding that I shouldn't need it if I was passing the xoauth_oauth2_access_token already?
I've checked all of the variables I.E. $credentials and $this->_c and all of the variables are passing through correctly.