PHP Classes

linkedIn not returning email address for oauth2

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  linkedIn not returning email address...  >  (Un) Subscribe thread alerts  
Subject:linkedIn not returning email address...
Summary:linkedIn not returning email address for oauth2
Messages:5
Author:Chris Trigg
Date:2014-11-30 11:29:13
 

  1. linkedIn not returning email address...   Reply   Report abuse  
Picture of Chris Trigg Chris Trigg - 2014-11-30 11:29:13
I've used the login_with_google.php and login_width_facebook.php, all working fine.


But when I fill out the usual in login_with_linkedin.php:
$client->client_id = 'xxx';
$client->client_secret = 'xxx';
$client->scope = 'r_emailaddress r_basicprofile r_contactinfo r_fullprofile';

And make sure the scopes are ticked in the linkedin developers console.
I only get a basic report back:

stdClass Object
(
[firstName] => name
[headline] => etc
[lastName] => lastname
[siteStandardProfileRequest] => stdClass Object
(
[url] => https://www.linkedin.com/profile/view?id=2xxxxxx1&authType=name&authToken=Hxxxxk=api*axxxxx*sxxxxx*
)

)

No email addr.

Can someone help?

Regards



  2. Re: linkedIn not returning email address...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-30 21:24:51 - In reply to message 1 from Chris Trigg
At least with OAuth 1.0a you need to use a different API call to get the email address from LinkedIn, provided you used the scope r_emailaddress .

api.linkedin.com/v1/people/~/email- ...

I did not try LinkedIn OAuth 2 authorization. Just let me know what API calls are you using if it does not work for you.

  3. Re: linkedIn not returning email address...   Reply   Report abuse  
Picture of Chris Trigg Chris Trigg - 2014-12-01 01:58:14 - In reply to message 2 from Manuel Lemos
Hi there,

I'm using the login_with_linkedin.php code supplied in this download (below), which i'm relatively sure is oauth2.
Since all the other login_with_*.php use oauth2.

The last post gave an output, and I can't see how to apply that to the linkedin API url-lookup stuff (and infact they have different keys)

Here is the code i'm using:
phpclasses.org/package/7700-PHP-Aut ...

What do I do from here?

[Strange that you have someone else at the same time asking oauth linkedin questions - its not me. perhaps the power of google?]

  4. Re: linkedIn not returning email address...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-12-01 02:08:45 - In reply to message 3 from Chris Trigg
No, this class supports both OAuth 1 and 2. In the case, LinkedIn support uses OAuth 1.0a.

To make API calls you should use the CallAPI function like in the login_with_linkedin.php script. To get the email address, you need to call this API URL:

api.linkedin.com/v1/people/~/email- ...

  5. Re: linkedIn not returning email address...   Reply   Report abuse  
Picture of Chris Trigg Chris Trigg - 2014-12-01 02:16:50 - In reply to message 4 from Manuel Lemos
Ahh thankyou!

For those who are wondering:
Change line 46 to this:

'http://api.linkedin.com/v1/people/~/email-address',

Cheers!