Hi Friends,
Getting errors at Jwt Builder and HMACSHA256Algorithm does not exist.I tried to install JWT through nuget and package console in our .net core 2.1 project but not installing.
string apiKey = "32a4ef";
string secretKey = "qloDZF";
int currtime = 163068;
var payload = new Dictionary<string, object>
{
{ "iss", apiKey },
{ "iat", currtime },
{ "jti", Guid.NewGuid().ToString() }
};
try
{
string token = new JwtBuilder()
.WithAlgorithm(new HMACSHA256Algorithm()) // symmetric
.WithSecret(secretKey)
.AddClaims(payload)
.Build();
Console.WriteLine(token);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Is there any other way to get the token similar to this code.