I have created a Azure AD B2C directory/tenant and created a new sign up/sign in user flow as per below:
Notice that the Identity Provider is set to user id signup (i.e. usernames).
I've created a user with the username hughbe.
When I get a JWT access token using the following code:
const { instance, accounts } = useMsal();
const token = await instance.acquireTokenSilent({account: accounts[0], scopes: ...});
I only get the following idTokenClaims
Is it possible to configure Azure AD B2C to include a user's username
field in the list of Application Claims? It doesn't appear in the list:
I tried to reproduce the same in my environment and got the below results:
In my B2C tenant, I created one Sign up and sign in user flow with same properties as you like below:
Now, I created one Azure AD B2C user with username as sri
like below:
When I ran the user flow, it displayed sign in screen with username as below:
If the user signs in successfully, they got code
in their address bar along with redirect Uri like this:
I used the above code
to generate token via Postman like below:
When I decoded this token, I got the same claims as you like below:
Please note that, it's not possible to include user's username
field in the list of Application Claims.
While running user flows, username
won't be returned as token claim. Alternatively, you can make use of custom policies by adding signinname
as output claim in the policy like below:
<OutputClaim ClaimTypeReferenceId="signinname" />
References:
SignUpOrSignin with_Username policy - GitHub by Sipower
Send the user principal name via claims - Stack Overflow by Jas Suri-MSFT