I am trying to write a method to generate JWT token in .net C#. Searching through internet I found pages demonstrating how do do this. One such page I am following is https://gist.github.com/pmhsfelix/4151369. To support this, I ran "Install-Package System.IdentityModel.Tokens.Jwt
" in the package manager console and can see "<package id="System.IdentityModel.Tokens.Jwt" version="4.0.2.205111437" targetFramework="net45" />"
in my paackages.config. But still, the SecurityTokenDescriptor is not found. I have a strong feeling it is some version mismatch but I am not able to find out what is it. Can some one help me fix this?
Make sure that in your code you use:
using System.IdentityModel.Tokens;
using Microsoft.IdentityModel;
Also, I believe you will need to add a reference to:
System.IdentityModel
which is found in the Assemblies tab in Visual Studio.
Hope this helps you.
After upgrading from 4.x.x to 5.x.x
Change this line:
using System.IdentityModel.Tokens;
To:
using System.IdentityModel.Tokens.Jwt;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With