Dibya Mani Suvedi
Dibya Mani Suvedi

Reputation: 21

How to include roles into access token using Azure AD MSAL library

My web api services are protected by roles based authorization. So, my access token requesting from Azure AD doesn't include any roles in access token. Is it possible to add assigned roles(defined in manifest file and adding it on user) into access token?

would you please guide me with links and examples because I am not able to find any documentations?

Upvotes: 2

Views: 2700

Answers (1)

juunas
juunas

Reputation: 58908

Definitely possible, I've written an older article on the topic: https://joonasw.net/view/defining-permissions-and-roles-in-aad.

Make sure you define the roles in the manifest of the API. Do note though that if a user has many roles and you use the implicit flow to get tokens in the front-end, they might not appear in the token. If that happens to you, upgrading to MSAL.js 2.x and using authorization code flow with PKCE in the front-end should help with this.

Upvotes: 1

Related Questions