Search code examples
phpoauthlinkedin-apiaccess-token

Linkedin OAuth callback not being called in PHP?


Just like this question with no answer, I am trying to hook up to Linked in through PHP/OAuth. I have gotten the token. Gotten everything working. But for some reason Linkedin will not return to my callback URL and asking for a PIN? help?

From the documentation this should only happen if there is no Callback url?

$token = $linkedInOAuth->getRequestToken();

array(5) {
  ["oauth_token"]=>
  string(36) "[valad_token]"
  ["oauth_token_secret"]=>
  string(36) "[valad_secret]"
  ["oauth_callback_confirmed"]=>
  string(4) "true"
  ["xoauth_request_auth_url"]=>
  string(44) "https://api.linkedin.com/uas/oauth/authorize"
  ["oauth_expires_in"]=>
  string(3) "599"
}

$linkedInOAuth->getAuthorizeURL($token, site_url('practice/linkedin_auth_callback'));

string(169) "https://api.linkedin.com/uas/oauth/authorize?oauth_token=[valad_token]&oauth_callback=http%3A%2F%2Fwww.core.me%2Fpractice%2Flinkedin_auth_callback"

The link is then put in a <a href="<?= $auth_url ?>">Click here to Auth Linked in</a> but when the user goes and logs in - it goes to the PIN page?


Solution

  • Looks like LinkedIn API uses Oauth 1.0a, you need to pass the callback url when you get the initial request token.

    See here

    Or take a read through the Oauth 1.0a spec

    They will store it, then when the user authorises the request token, it will callback to the url stored against that request token.