Arash Nsi
Arash Nsi

Reputation: 40

jwt claim on blazor web assembly and web api claim

when i generate jwt token on server, one of my claim is ClaimType.Name, but in blazor web assembly when i parse jwt token and get claims, it's name changed to unique_name.

can anyone explain why this is happen?

on server

new Claim(ClaimTypes.Name, user.Username);

on blazor web assembly

"unique_name" = "myUsername"

Upvotes: 1

Views: 565

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273464

This is by design. This post has the details with excerpts from the JwtSecurityTokenHandler code.

The rule you found is from this Dictionary entry that is used to do a mapping:

{ JwtRegisteredClaimNames.UniqueName, ClaimTypes.Name },

Basically, Microsoft Identity Claims are converted (when appropriate) to JWT standard names.

Upvotes: 2

Related Questions