How to get ClaimsPrincipal from ADAL AuthenticationResult

I am using the Azure Active Authentication Library to log users into a WPF application. After the call, AuthenticationContext.AcquireToken()I get AuthenticationResultwith some UserInfo, but not provides ClaimsPrincipal, which uses my application. In addition, it System.Security.Claims.ClaimsPrincipal.Currentreturns only an empty main object with no claims filled by it. How can I get ClaimsPrincipalfor a registered user?

+4
source share
1 answer

AuthenticationResult.AccessToken is the JWT token that represents the user. You can use http://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/5.0.0-rc1-211161024 to read the token and create the main application. The api for the JwtSecurityTokenHandler.ValidateToken accepts TokenValidationParameters parameters that can be used to verify the visibility.

All that is said, depending on what you need (you may not need ClaimsPrincipal), you may need to look at the AuthenticationResult.UserInfo property.

+1
source

Source: https://habr.com/ru/post/1628035/


All Articles