【问题标题】:LinkedIN API call returns only half the profile valuesLinkedIN API 调用仅返回一半的配置文件值
【发布时间】:2017-03-08 14:24:44
【问题描述】:

尝试将带有 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 获取的内容并得到了这个:

如您所见,根据 LinkedIn (https://developer.linkedin.com/docs/fields/basic-profile),只有 11 个字段,但应该有更多字段

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

谢谢

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      事实证明我确实可以访问我需要的东西。只是我不得不打电话给https://api.linkedin.com/v1/people/~:(firstName,lastName,picture-url)?oauth2_access_token=

      【讨论】:

        猜你喜欢
        • 2019-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-12
        • 2016-11-28
        • 2011-12-26
        • 2013-05-16
        • 2016-02-11
        相关资源
        最近更新 更多