如何从.net core 2中的临时cookie中读取外部标识

时间:2017-09-25 16:28:38

标签: identityserver4 asp.net-core-2.0

[HttpGet("ExternalLoginCallback")]
        public async Task<IActionResult> ExternalLoginCallback(string returnUrl)
        {
            // read external identity from the temporary cookie
            var info = await HttpContext.Authentication.GetAuthenticateInfoAsync(IdentityServerConstants.ExternalCookieAuthenticationScheme);
            var tempUser = info?.Principal;
            if (tempUser == null)
            {
                throw new Exception("External authentication error");
            }

            // retrieve claims of the external user
            var claims = tempUser.Claims.ToList();

这是使用IdentityServer4的外部登录回调片段。我已迁移到.net core 1 to 2并且我收到警告HttpContext.Authentication' is obsolete: 'This is obsolete and will be removed in a future version.那么,在.net core 2中引入哪种方法来获取身份?

1 个答案:

答案 0 :(得分:0)