Im trying to get user properties from oauth2 token, using login microsoft request, but i just get the email in token claims. Is there a way to get the username in token claims?
In my case, I created one custom attribute named username
in my B2C tenant like this:
In your Sign Up and Sign In flow, make sure to include username
attribute before running it:
When new user is signing up, it will ask the user to enter the username again like this:
Before generating token using ROPC flow, make sure to include username
in Application claims like this:
Now, I generated access token via Postman with below parameters:
POST https://<b2ctenant_name>.b2clogin.com/b2ctenant.onmicrosoft.com/B2C_1_ROPC_Auth/oauth2/v2.0/token
grant_type:password
client_id: appId
scope:openid <appId> offline_access
username: <username>
password:xxxxxxx
Response:
When I decoded this token in jwt.ms website, I got username in token claims successfully like this:
Reference:
How to get the signin-name(username) as a claims after login - Microsoft Q&A by AmanpreetSingh-MSFT