I'm using Azure Active Directory Authentication Library to sign-in users in a WPF application. After call to AuthenticationContext.AcquireToken()
I get AuthenticationResult
with some UserInfo
but it does not provide a ClaimsPrincipal
which my application uses. Also System.Security.Claims.ClaimsPrincipal.Current
returns only an empty principal object with no claims populated in it. How do I get the ClaimsPrincipal
for the signed-in user?
The AuthenticationResult.AccessToken is a 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 a claims principal. the api for the JwtSecurityTokenHandler.ValidateToken takes a TokenValidationParameters that can be used to scope validation.
All that said, depending on what you need (perhaps you don't need a ClaimsPrincipal), you might want to have a look at the AuthenticationResult.UserInfo property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With