LinkedIN API 调用 returns 只有一半的配置文件值
LinkedIN API call returns only half the profile values
正在尝试将 register/login 与 LinkedIN 功能添加到我的网络应用程序。这是我调用 api.
的 ExternalLoginCallback 方法
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
var externalIdentity = HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);
var firstName = externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname").Value;
var lastName = externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname").Value;
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email, Name = firstName });
}
}
尝试捕获 externalIdentity 从 linkedIN 获取的内容并得到:
如您所见,只有 11 个字段,根据 LinkedIn (https://developer.linkedin.com/docs/fields/basic-profile)
我怎样才能得到其余的?喜欢图片URL,还是第二个位置? (出于某种原因,它只有 returns 第一个)
谢谢
您需要完整的个人资料权限才能访问所有字段。要获得完整个人资料权限,您必须是 LinkedIn 合作伙伴。
合作伙伴计划申请表:https://developer.linkedin.com/partner-programs/apply
原来我确实可以访问我需要的东西。只是我不得不打电话给 https://api.linkedin.com/v1/people/~:(firstName,lastName,picture-url)?oauth2_access_token=
正在尝试将 register/login 与 LinkedIN 功能添加到我的网络应用程序。这是我调用 api.
的 ExternalLoginCallback 方法 public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
var externalIdentity = HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);
var firstName = externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname").Value;
var lastName = externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname").Value;
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email, Name = firstName });
}
}
尝试捕获 externalIdentity 从 linkedIN 获取的内容并得到:
如您所见,只有 11 个字段,根据 LinkedIn (https://developer.linkedin.com/docs/fields/basic-profile)
我怎样才能得到其余的?喜欢图片URL,还是第二个位置? (出于某种原因,它只有 returns 第一个)
谢谢
您需要完整的个人资料权限才能访问所有字段。要获得完整个人资料权限,您必须是 LinkedIn 合作伙伴。
合作伙伴计划申请表:https://developer.linkedin.com/partner-programs/apply
原来我确实可以访问我需要的东西。只是我不得不打电话给 https://api.linkedin.com/v1/people/~:(firstName,lastName,picture-url)?oauth2_access_token=