0
我試圖從登錄使用鏈接它的用戶獲取用戶ID。鏈接在Oauth登錄異常
我可以登錄並獲取訪問令牌。但我的下面的try語句失敗,並給我這個異常「System.NotImplementedException:所請求的功能未實現。」
任何意見如何我可以得到用戶ID?
try
{
var request = HttpWebRequest.Create(string.Format(@"https://api.linkedin.com/v1/people/~:(id)?oauth2_access_token=" + access_token + "&format=json", ""));
request.ContentType = "application/json";
request.Method = "GET";
var user_ID = values["user_id"];
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
System.Console.Out.WriteLine("Stautus Code is: {0}", response.StatusCode);
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
var content = reader.ReadToEnd();
if (!string.IsNullOrWhiteSpace(content))
{
System.Console.Out.WriteLine(content);
}
var result = JsonConvert.DeserializeObject<dynamic>(content);
}
}
}
catch (Exception exx)
{
System.Console.WriteLine(exx.ToString());
}
登錄功能工作。
var auth = new OAuth2Authenticator(
clientId: "MYID",
clientSecret: "SECret",
scope: "r_basicprofile",
authorizeUrl: new Uri("https://www.linkedin.com/uas/oauth2/authorization"),
redirectUrl: new Uri("http://adults.wicareerpathways.org/"),
accessTokenUrl: new Uri("https://www.linkedin.com/uas/oauth2/accessToken")
);
auth.AllowCancel = true;
auth.Completed += (sender, eventArgs) => {
if (eventArgs.IsAuthenticated)
{
string dd = eventArgs.Account.Username;
var values = eventArgs.Account.Properties;
var access_token = values["access_token"];
// var user_ID = values["user_id"];
if (linkedinLoginCompleted != null)
{
var LinkedInAccount = new Mobile.LinkedIn.Account
{
Username = eventArgs.Account.Username,
Properties = eventArgs.Account.Properties
};
linkedinLoginCompleted(LinkedInAccount);
}