C# – Exception using System.IdentityModel.Tokens.Jwt 5.0.0.127 in Web Api 2 built on .Net 4.6

asp.netasp.net-web-apiasp.net-web-api2cnet

I have updated my existing Web Api project to use the latest System.IdenityModel.Tokens.Jwt package and I am getting the following error:

Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.

Everything works fine with 4.0 version of the same package. How can I resolve this?

Best Answer

If you want to use the new version(v5) of System.IdentityModel.Tokens.Jwt and don't want to restrict your project to the v4 version, I have created a Nuget and Github project called EasyJwtAuth that uses v5(Very simple to use):

Nuget package: https://www.nuget.org/packages/EasyJwtAuth

Instructions on how to use: https://github.com/Xela101/EasyJwtAuth

Feel free to update the repository with more features, or just learn/copy the code and make your own authentication wrapper.