2016-10-26 52 views
0

嘗試將LinkedIN功能的註冊/登錄添加到我的Web應用程序。這裏是我調用api的ExternalLoginCallback方法。LinkedIN API調用只返回配置文件值的一半

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

,你可以看到,只有11場,當應該有更多,根據LinkedIn(https://developer.linkedin.com/docs/fields/basic-profile

我怎樣才能得到其餘的?像圖片網址,還是第二個位置? (由於某種原因,它只返回第一個)

謝謝

回答

相關問題