Why is ClaimTypes.NameIdentifier not mapping to ‘sub’?

  1. To not let Microsoft Identity to override claim names you have to use JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); just before the app.UseAuthentication() in the API startup.

  2. Use direct “sub” claim instead of ClaimThypes.NameIdentifier e.g.
    var id = this.User.FindFirstValue("sub");

For further reference please see detailed discussion on it:
https://github.com/IdentityServer/IdentityServer4/issues/2968#issuecomment-510996164

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)