1

enter image description here

here is my JWT. My HttpContext.User doesn't match with JWT.

here my httpcontext: httpContext

Plese help me...

Program.cs: enter image description here

  • So you mean you see different claim values in the User compared to the token? can you post the complete access token to the question, including the header (from jwt.io). Often the problem is that you have different claim names, but if you see different values, then its either due to session cookies or that you are sending the wrong access token. – Tore Nestenius Feb 13 '22 at 07:11
  • thank you. header: { "alg": "HS256", "typ": "JWT" } frome jwt.io – otter otter Feb 13 '22 at 07:50

1 Answers1

2

Usually,setting the MapInboundClaims=false should stop the library from renaming your claims.

But you could try to add the following to your startup class:

public void ConfigureServices(IServiceCollection services)
{
    // By default, Microsoft has some legacy claim mapping that converts
    // standard JWT claims into proprietary ones. This removes those mappings.
    JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
    JwtSecurityTokenHandler.DefaultOutboundClaimTypeMap.Clear();
    ..
Tore Nestenius
  • 16,431
  • 5
  • 30
  • 40