CLOSED: Can we get email address? [ONLY FOR AUTHORIZED MEMBER]

48 posts / 0 new
Last post
Kamlesh Chettiyar's picture
Joined: 2012-01-16
Aug 7, 2012
CLOSED: Can we get email address? [ONLY FOR AUTHORIZED MEMBER]

Hi,

I took the permission for email address by sending scope value(r_emailaddress) after that I got the token and secret. Even, I could fetch basic information. But, when I tried to fetch email address gives the null value.

The URL is "http://api.linkedin.com/v1/people/~/email-address".
Even, I got a mail from linkedin@e.linkedin.com saying that from now, we could fetch the email address.

Please help me out with this.

Thanks,

Sorin Neacsu's picture
Joined: 2012-01-13
Aug 8, 2012

Looks like its not working. Possibly the new API didnt propagate to everybody. I still get the old Auth dialog, even for a new API key.

Tomasz Cejner's picture
Joined: 2012-06-11
Aug 8, 2012

Same in my case. I too noticed new look of OAuth dialog in documentation, has this changed recently?

Sorin Neacsu's picture
Joined: 2012-01-13
Aug 8, 2012

Yeah it's changed. If you still see the old one you're on the old API.

Tomasz Cejner's picture
Joined: 2012-06-11
Aug 8, 2012

Solved! I added my application again, and new API keys work: I have new authentication dialog and email.

Chris Kirby's picture
Joined: 2012-05-25
Aug 8, 2012

I have tried making a new application and also added the scope to the request as stated in your docs and still I am getting the old Auth dialog with no email permissions.

Am I missing something?

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Aug 8, 2012

Hi everyone, hang tight. The new auth flow is slowly rolling out to everyone and should be available to 100% of our developers by the end of today.

As of now the new auth flow only applies to new applications registered with us. We're still working on a migration plan for existing apps.

Thanks,
Kamyar

Ryan Shillington's picture
Joined: 2012-02-26
Aug 9, 2012

I can confirm that I added a new "application", updated my API key & Secret Key in my code, and now it works.

Sorin Neacsu's picture
Joined: 2012-01-13
Aug 9, 2012

Yeah its working now! Thanks Kamyar for the info.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Aug 9, 2012

No problem, enjoy!

Maxwell Cabral's picture
Joined: 2012-07-11
Aug 9, 2012

Thanks for the new addition. This is great. It really dramatically decreased the complexity of our LinkedIn reg flow.

Is there an ETA for migrating existing API keys over? If I may be so bold as to offer a suggestion, if you didn't automatically switch everyone over because of breaking changes to the API, you might want to follow what Facebook does. In your app settings there are checkboxes to select/deselect breaking API updates. That would probably be the way to make everyone happy.

Edit: missed a word

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Aug 9, 2012

Hi Maxwell, I don't have a specific date on the migration, but it most likely won't be automatic. We'll give our developers the option to migrate specific API keys should they choose to do so.

Andy Nguyen's picture
Joined: 2012-03-19
Aug 10, 2012

Kamyar Mohager wrote:
> Hi Maxwell, I don't have a specific date on the migration, but it most
> likely won't be automatic. We'll give our developers the option to migrate
> specific API keys should they choose to do so.

Shall I assume that LinkedIn will make an announcement when the "option to migrate specific API key" becomes available?
Thanks.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Aug 13, 2012

Hi Andy, you can safely assume that :) We'll make an announcement to our developers when this happens.

Thanks,
Kamyar

Joined: 2012-10-11
Oct 12, 2012

I've tried in vain to use the new LinkedIn Api's to get the email address using "requestToken?scope=r_basicprofile+r_emailaddress" using C#, Hammock rest library. My request path is like this
"var request = new RestRequest { Path = "people/~/email-address" };

As indicated by Tomasz Cejner, created a new application to get fresh set of api keys however I still cannot get email.

Any guidance will be appreciated.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Oct 12, 2012

With Hammock, can you try to URL encode the request token path and see if it works:

Change "requestToken?scope=r_basicprofile+r_emailaddress" to "requestToken?scope=r_basicprofile%2Br_emailaddress". Let me know if that works. If that's the case we may need to be more explicit about this since some libraries don't like the "+" shorthand

Kamyar

Joined: 2012-10-11
Oct 14, 2012

Hello Kamyar,

Tried your suggestion however I get "Access to email-address is denied" error message on requesting email address.
How can I get email address?

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Oct 15, 2012

Can you show me how you're requesting the member permission for email address?

Joined: 2012-10-11
Oct 15, 2012

This is how I'm requesting member permission for email address

var credentials = new OAuthCredentials
{
CallbackUrl = "http://myurl:5645/Callback.aspx",
ConsumerKey = "myconsumerkey",
ConsumerSecret = "myconsumersecret",
Type = OAuthType.RequestToken,
};
var client = new RestClient
{
Authority = "https://api.linkedin.com/uas/oauth",
Credentials = credentials
};
var request = new RestRequest
{
Path = "requestToken?scope=r_basicprofile%2Br_emailaddress",
};
RestResponse response = client.Request(request);

String[] strResponseAttributes = response.Content.Split('&');
string token = strResponseAttributes[0].Substring(strResponseAttributes[0].LastIndexOf('=') + 1);
string authToken = strResponseAttributes[1].Substring(strResponseAttributes[1].LastIndexOf('=') + 1);

Session["Token"] = token;
Session["TokenSecret"] = authToken;

Response.Redirect("https://www.linkedin.com/uas/oauth/authorize?oauth_token=" + token);

Then I try read the user's email using this code

var request = new RestRequest { Path = "people/~/email-address" };

var credentials = new OAuthCredentials
{
Type = OAuthType.AccessToken,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
ConsumerKey = "myconsumerkey",
ConsumerSecret = "myconsumersecret",
Token = Session["AccessToken"].ToString(),
TokenSecret = Session["AccessSecretToken"].ToString(),
Verifier = Session["Verifier"].ToString()
};

var client = new RestClient()
{
Authority = "http://api.linkedin.com/v1",
Credentials = credentials,
Method = WebMethod.Get
};
var userEmail = client.Request(request);
String content = userEmail.Content;

What am I missing or doing wrong? Thanks for your continued support

I'm also guessing that the new Api has not been propagated to everyone since I still get the old Authentication dialog.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Oct 16, 2012

Hi Subham,

Your last sentence gave me all the info I needed :) Since you're using an API key that was created prior to the platform updates in August, you won't be able to take advantage of member permissions (yet). We're working on a migration that will be out soon where you can opt-in your existing API key to be able to leverage these updates. For now I suggest that if you've already invested a great amont of development with your existing API key to wait for the migration. Otherwise, if you're just playing around with the platform or just started development, register for a new API key: https://www.linkedin.com/secure/developer

Thanks,
Kamyar

Joined: 2012-10-11
Oct 16, 2012

Hi Kamyar,

My current API keys were created in the first week of October 2012. I had updated it once already, however I registered for new API keys but I still get "Access to email-address is denied" error message on requesting email address. What else can I try? Thanks for your co-operation. I'm using https://developer.linkedin.com/documents/authentication as a reference, is this the newer API or I'm on the wrong link.

I read that only allows companies that have partner agreement with Linkedin have access to email addresses from the API. Is this even true?

Rajesh Kasani's picture
Joined: 2011-09-14
Oct 17, 2012

Hi Kamyar,
I have a little problem while fetching email id from linkedin.

The authentication process is going on smoothly but while fetching user standard profile i could not get the email address even though i am requesting it(with the authenticated token to get email). do i need to write and api call to manually fetch the email id or the standard or full profile api call fetches the email id of the user.
I have checked the example in documentation to fetch standard and full profile none contained email in docs..
so do i have to write and additional api call or linkedin api is going to send it by default if i'm fetching standard profile.

If there is an other endpoint to fetch all the details with email please do notify..
Thanks for your time.
Rajesh kasani.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Oct 17, 2012

@Subham: When building your request token URL try to encode space with %20 and let me know if that work: "requestToken?scope=r_basicprofile%20r_emailaddress". Also, you don't need to explicitly request r_basicprofile because by default all apps are given that permission.

@Rajesh: As long as you're requesting the email member permissions, you can fetch the email with an API call like this:

GET http://api.linkedin.com/v1/people/~:(email-address)

Joined: 2012-10-11
Oct 18, 2012

@Kamyar,

Tried %20, still giving me Access to email-address is denied.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Oct 19, 2012

Subham, remove the r_basicprofile permission from the URL since it's already explicitly granted

Joined: 2012-10-11
Oct 25, 2012

Kamyar,

Removed r_basicprofile and tried with just r_emailaddress, however same access to email-address denied error

Shikha A. Sehgal's picture
LinkedIn Employee
Joined: 2012-07-27
Oct 25, 2012

hey Subham:

Can you please show how you are accessing the member permission for email address and also the http request that you are making. Want to see what's going on in there as now with the r_basicprofile permission removed there should not be any encoding issue with the just the r_emailaddress permission.

Leon Henry's picture
Joined: 2012-10-22
Oct 25, 2012

works ok here .. "~/email-address" and passing /uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress

Joined: 2012-10-11
Oct 26, 2012

Shikha,

I'm pasting code below for your review. Never mind the commented code as I was trying different ways to encode the request for email permission along with r_basicprofile. I'm using the Hammock library referenced in Libraries and Tools (http://developer.linkedin.com/documents/libraries-and-tools) to make rest calls with C# and asp.net 4.0

string linkedinconsumerkey = ConfigurationManager.AppSettings["linkedinconsumerkey"];
string linkedinconsumersecret = ConfigurationManager.AppSettings.Get("linkedinconsumersecret");

var credentials = new OAuthCredentials
{

CallbackUrl = "http://localhost:2715/Callback.aspx",

ConsumerKey = linkedinconsumerkey,

ConsumerSecret = linkedinconsumersecret,

Type = OAuthType.RequestToken,

};

var client = new RestClient
{
Authority = "https://api.linkedin.com/uas/oauth/",
Credentials = credentials,

};

//var scope = HttpUtility.UrlEncode("r_basicprofile r_emailaddress");
//var scope = HttpUtility.UrlPathEncode("r_basicprofile r_emailaddress");
//var scope = Uri.EscapeUriString("r_basicprofile r_emailaddress");
//var scope = Uri.EscapeDataString("r_basicprofile r_emailaddress");

var request = new RestRequest
{
Path = "requestToken?scope=r_emailaddress",
};

RestResponse response = client.Request(request);

String[] strResponseAttributes = response.Content.Split('&');
string token = strResponseAttributes[0].Substring(strResponseAttributes[0].LastIndexOf('=') + 1);
string authToken = strResponseAttributes[1].Substring(strResponseAttributes[1].LastIndexOf('=') + 1);

Session["Token"] = token;
Session["TokenSecret"] = authToken;

Response.Redirect("https://www.linkedin.com/uas/oauth/authorize?oauth_token=" + token);

Now to access email I do the following

string linkedinconsumerkey = ConfigurationManager.AppSettings["linkedinconsumerkey"];
string linkedinconsumersecret = ConfigurationManager.AppSettings.Get("linkedinconsumersecret");
var request = new RestRequest { Path = "people/~/email-address" };

var credentials = new OAuthCredentials

{

Type = OAuthType.AccessToken,

SignatureMethod = OAuthSignatureMethod.HmacSha1,

ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,

ConsumerKey = linkedinconsumerkey,

ConsumerSecret = linkedinconsumersecret,

Token = Session["AccessToken"].ToString(),

TokenSecret = Session["AccessSecretToken"].ToString(),

Verifier = Session["Verifier"].ToString()

};

var client = new RestClient()
{
Authority = "http://api.linkedin.com/v1/",
Credentials = credentials,
Method = WebMethod.Get
};

var MyInfo = client.Request(request);

String content = MyInfo.Content;

Thanks for your interest in attempting to resolve this issue.

Roland Hedberg's picture
Joined: 2011-11-23
Oct 29, 2012

I sort of have the same problem as several others. Even though I ask for the email and the user sees that and acknowledges it I don't get it.
But what is worse I don't get the 'id'. I get lastName, firstName, headline and siteStandardProfileRequest. But no id and no email.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Nov 8, 2012

Hi everyone,

We're happy to announce that we've released the option to opt-in your API key to take advantage of member permissions (including being able to fetch email address). This document will help guide you through the migration:

https://developer.linkedin.com/documents/member-permissions-migration-guide

Thanks to everyone for their patience and continued support of our platform!

- Kamyar

Matt Roden's picture
Joined: 2012-02-24
Nov 22, 2012

For anyone still struggling with scope using Hammock, this worked for me:

https://developer.linkedin.com/comment/19914#comment-19914

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Nov 26, 2012

Thanks for the update, Matt!

David Edwards's picture
Joined: 2012-11-05
Nov 28, 2012

Kamyar, I have just read through the member permissions migration guide and cannot see any option on my application details to set or change member permissions??

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Nov 28, 2012

If you go to your application details page (https://www.linkedin.com/secure/developer) you should see a check box towards the bottom that read:

Use Member Permissions: [checkbox] Permanently upgrade your API key to use member permissions.

If you don't see this, then your API key already uses member permissions. Remember, the migration is only necessary if you registered your API key before Aug 6, 2012. If it was created afterwards, you don't need to migrate.

Joined: 2012-12-23
Dec 26, 2012

Kamyar,I am able to authenticate with Linkedin Api but unable to fetch email-address.
I am using the following link to fetch email Id
https://api.linkedin.com/uas/oauth/requestToken?scope=r_fullprofile+r_emailaddress+r_contactinfo
after calling to this link it is throwing error message as "The remote server turned an error(401)Unauthorized."

Subrata Sarkar (Niladri)'s picture
Joined: 2012-04-11
Feb 17, 2013

Even though they have added it in the permission list, after authentication, email is "undefined". I created my application only a week ago. Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxxxxxxxxx
scope: r_basicprofile r_emailaddress
onLoad: onLinkedInLoad
authorize: true
</script>
</head>
<body>
<script type="IN/Login" data-onauth="onLinkedInAuth"></script>
<div id="profiles"></div>
</body>
<script type="text/javascript">

/* ------ LinkedIn --------*/
function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth);
}

function onLinkedInAuth() {
window.IN.API.Profile("me").result(displayProfiles);
}

function displayProfiles(profiles) {
var member = profiles.values[0];
document.getElementById("profiles").innerHTML =
"<p id=\"" + member.id + "\">Hello " + member.firstName + " " + member.lastName + "<br />" + member.emailAddress + "</p>";
}
</script>
</html>

Am I missing something? Please help.

Joined: 2012-09-24
Feb 18, 2013

i have the questions. Is it possible to get email addresses of account connections?
i use scope r_network to take the connections.
My request looks like that:
...
$token = $consumer->getRequestToken(array('scope' => 'r_network'));
...
$client->setUri('http://api.linkedin.com/v1/people/~/connections:(id,first-name,last-name,picture-url,public-profile-url,email-address)');
p.s. i use zend framework.

Kamyar Mohager's picture
LinkedIn Employee
Joined: 2012-04-04
Feb 20, 2013

Email address is only available for the authenticated user.

Thanks,
Kamyar

Jairo Sanches's picture
Joined: 2013-07-11
Jul 15, 2013

Working here in objective C.
I'm able to get the e-mail address using this:

Good request:
http://api.linkedin.com/v1/people/v1/people/~:(id,first-name,last-name,email-address)

Jairo Sanches's picture
Joined: 2013-07-11
Jul 15, 2013

I'm able to get the e-mail address using this:

Good request:
http://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address)

mehta vishal's picture
Joined: 2012-05-26
Sep 12, 2013

hi i want to fetch the address book record in my site using c # from linkedin account how ?

Joined: 2013-12-24
Dec 26, 2013

please use http://api.linkedin.com/v1/people/~:(email-address)

this can be use get own email adress.

Joined: 2014-02-11
Feb 13, 2014

Hi Every one
I want to connect some one who is not my network. may i know member of email id.

Devasena Inupakutika's picture
Joined: 2014-02-08
Mar 5, 2014

Can we get our connections email-address through api as when I tried after requesting member permissions and with primary endpoint GET /people/~/connections:(email-address) , this doesn't return anything?

Lee Fu's picture
LinkedIn Employee
Joined: 2013-06-19
Mar 5, 2014

Devasena,

You can get email address only for the user who is logged into your application.

Thanks,
-Lee

Shoham Nicolet's picture
Joined: 2011-12-20
Mar 25, 2014

did u got that to work?

can u get the email from javascipt?

Lee Fu's picture
LinkedIn Employee
Joined: 2013-06-19
Mar 26, 2014

You cannot get connection email addresses.

Topic locked