I'm using MSAL to perform authentication against Azure B2C. When a login is performed, I get a set of tokens. If I use:
authority: https://<<mytenent>>.b2clogin.com/<<mytenent>>.onmicrosoft.com/<<mypolicy>>
I get a id token and refresh token. But if I use
authority: https://login.microsoftonline.com/<<mytenent>>.onmicrosoft.com
(deprecated)
I also get an access token.
What I want is to use B2C, my own sign-in policy and get an access token. And I need that access token to contain the list of roles and groups that the user belongs to.
But when I perform a login using b2c, I can only request scopes openid
, offline_access
and profile
.
How do I get a list of roles and groups for a user in an access token using MSAL and B2C?
Add custom attributes in Azure AD B2C tenant:
Application claims:
To get access token in Azure AD B2C, you must pass scope as the API:
In the token, claims will be displayed:
I agree with @rbrayb you can call Microsoft Graph API to get the Group claims by referring to this GitHub Blog by damienbod
To get groups user is member of:
Reference:
Azure AD B2C - assigning group-based roles and creating custom roles