Hi @Abhishek ,
You can try the following steps to identify what’s causing the difference in parsed claims between your deployed and test versions. These are some common areas where differences usually appear, even when the JWT authentication module itself hasn’t changed
- Different token source Check if the test environment is receiving the same JWT as production. In some cases, the identity provider or token issuer for the test app issues a slightly different token (for example, fewer claims or a different scope).
- Configuration differences
Even small differences in
appsettings.jsonor environment variables (such as issuer, audience, orTokenValidationParameters) can affect which claims are recognized or filtered out. - Claim mapping behavior
ASP.NET automatically maps certain claim types (like
sub→nameidentifier). If one environment clears the default claim type map (JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear()) and the other doesn’t, the claims collection may look different. - Middleware order or missing components
Make sure the test deployment has the same middleware setup — for example,
UseAuthentication()andUseAuthorization()should appear in the same order as production. If a custom middleware modifies claims, verify it’s included in both versions. - Build or dependency differences Sometimes the build or NuGet package versions differ slightly between environments, especially if one is rebuilt with newer dependencies.
To narrow it down:
- Decode both JWTs using jwt.io and confirm whether the missing claims are actually present in the token.
- Log or inspect
User.Claimsright after authentication in both environments. - Compare the full authentication configuration and middleware order between the two deployments.
Even if the code looks identical, environmental or configuration differences are usually the cause of this kind of behavior.
If you find any discrepancies or still see missing claims after checking these areas, please share the relevant configuration snippet or token payload (without sensitive data) so I can help you look deeper into it.