I have a .NET 6 web API that attempts to validate a JWT Bearer token with the following code:
objReturn = new JwtSecurityTokenHandler().ValidateToken(strJwtToken,
new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
IssuerSigningKey = objSecurityKey,
ClockSkew = TimeSpan.Zero
}, out objSecurityToken);
This works fine; however, I upgraded my NuGet packages today and now I am receiving the following error for all versions of the Microsoft.IdentityModel.Tokens
package starting at version 6.29:
{"Method not found: 'Boolean Microsoft.IdentityModel.Tokens.TokenUtilities.IsRecoverableConfiguration(Microsoft.IdentityModel.Tokens.TokenValidationParameters, Microsoft.IdentityModel.Tokens.BaseConfiguration, Microsoft.IdentityModel.Tokens.BaseConfiguration ByRef)'."}
What's weird is that the method appears to still be there as I went to it's NuGet.org page, which linked me to it's source repo on GitHub. This missing method appears to be there - it can be found here, starting on line 203.
Any ideas what is going on and how to fix?
UPDATE:
I used the example on how to validate a JWT token from this site: https://jasonwatmore.com/post/2022/01/19/net-6-create-and-validate-jwt-tokens-use-custom-jwt-middleware
Microsoft.AspNetCore.Authentication.JwtBearer
, theMicrosoft.IdentityModel.Tokens
namespace will be provided, and theMicrosoft.IdentityModel.Tokens
package does not need to be installed. Can you provide a minimal reproducible example? – PantherMicrosoft.AspNetCore.Authentication.JwtBearer
v6.0.20. When I navigate the package tree, I seeMicrosoft.IdentityModel.Tokens
v6.0.24, which is a few versions behind the maximum that I can run. So, this leads me to think that this is not the issue. I have updated my question with how to replicate. – Poulin