I'm using the Hammock library and C# to get the basic profile and email address of user from linked in following post here .
I've also followed these posts here and here
However for the life of me I cannot get the email address of the linkedin user.
Reading this linkedin post I got new created a new application to get new keys however still no luck.
Went through this linkedin post but could not get it to work either
I'm posting the code below but it's heavily lifted form the links I followed
var credentials = new OAuthCredentials
{
CallbackUrl = "http://localhost:2715/Callback.aspx",
ConsumerKey = "my consumer key",//not shown
ConsumerSecret = "my consumer secret",//not shown
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 request = new RestRequest
{
Path = "requestToken?scope=r_basicprofile+r_emailaddress",
};
I get this screen when user navigates to linkedin.
To actually request the email I use this code below
var request = new RestRequest { Path = "people/~/email-address" };
var credentials = new Hammock.Authentication.OAuth.OAuthCredentials
{
Type = OAuthType.AccessToken,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
ConsumerKey = "my consumer key", //not shown
ConsumerSecret = "my consumer secret", //not shown
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;
This is the error I get on MyInfo.Content
Thanks in advance for your help.
On trying Kamyar's suggestion I get the following error message. What else should I try?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…