LinkedIN API调用仅返回配置文件值的一半

时间:2016-10-26 09:31:11

标签: c# asp.net-mvc-5 oauth-2.0 linkedin-api

尝试使用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获得的内容并得到了这个:

enter image description here

正如你所看到的,根据LinkedIn(https://developer.linkedin.com/docs/fields/basic-profile

,只有11个字段,应该有更多字段

我怎样才能掌握其余部分?喜欢图片网址,还是第二个位置? (由于某种原因,它只返回第一个)

由于

2 个答案:

答案 0 :(得分:1)

您需要完整的个人资料权限才能访问所有字段。要获得完整的个人资料许可,您必须是LinkedIn合作伙伴。

合作伙伴计划申请表:https://developer.linkedin.com/partner-programs/apply

答案 1 :(得分:0)

原来我可以访问我需要的内容。只是我不得不打电话给https://api.linkedin.com/v1/people/~:(firstName,lastName,picture-url)?oauth2_access_token=