Azure easy auth get user role based on AD user Id ASP.net core app WebAPI

559 Views Asked by At

I'm following link to make authentication and authorization.

I able to create successfully token based on https://login.microsoftonline.com/{tenantID}/oauth2/token

After that I calling GET API using sayhello. It's everything fine, but I want based on token and UserId/Password of AD user get user role. I search a lot but not getting any concrete solution.

1

There are 1 best solutions below

0
On

To decode the Azure Active Directory JWT token using the tool, you can use this online decode tool JSON Web Tokens - jwt.io.

Here is an example covered of how to verify and decode Azure Active Directory Token, refer this article.

If you want to manually decode a bearer token using azure active directory, you can use JwtBearer or AddAzureADBearer middleware to validate the access token.

Please refer this thread which contains code to decode a bearer token.