Octavius
Octavius

Reputation: 583

LinkedIn Api - Uncaught exception 'OAuthException'

I'm currently attempting to install a login button for LinkedIn onto my website. I'm trying to go step by step as the developers section shows. After I wrote the code to get a request token and checked it using print_r.

define("my consumer key");
define("my consumer secret");

$oauth = new OAuth(my consumer key, my consumer secret);

//The first item of business is getting a request token
$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');

if($request_token_response === FALSE) {
        throw new Exception("Failed fetching request token, response was:"
        . $oauth->getLastResponse());
} else {
        $request_token = $request_token_response;
}

print "Request Token:\n";
printf("    - oauth_token        = %s\n", $request_token['oauth_token']);
printf("    - oauth_token_secret = %s\n", $request_token['oauth_token_secret']);
print "\n";

I got "Fatal error:Uncaught exception 'OAuthException'...Peer certificate cannot be authenticated with known CA certificates". The line that was called for the error is below

$request_token_response = $oauth->getRequestToken('https://api.linkedin.com/uas/oauth/requestToken');

I am not understanding what that error is trying to tell me so that I can fix the problem. I would appreciate and tips or guidance to help me better understand what this error message is trying to convey and how to fix it.

Upvotes: 3

Views: 1828

Answers (1)

Ifthikhan
Ifthikhan

Reputation: 1474

It seems that the library is trying to verify the SSL certificate and it cannot do so. You could disable ssl checks via the method OAuth::disableSSLChecks. I assume you are using the following pecl extension http://www.php.net/manual/en/class.oauth.php. If not the client library you are using should have a method to disable the SSL certificate verification.

....
...
$oauth = new OAuth(my consumer key, my consumer secret);   
$oauth->disableSSLChecks();
..
...

Ideally you would do it right after instantiation

Upvotes: 4

Related Questions