I have code to generate JWT token:
var utcNow = DateTime.UtcNow;
var utcNowUnix = (Int32)(utcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var expirationTimeUtcUnix = (Int32)(utcNow.AddHours(6).Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var payload = new JwtPayload
{
{"sub", "xxxxxxxx"},
{"iat", utcNowUnix},
{"exp", expirationTimeUtcUnix }
};
var headers = new JwtHeader
{
{ "alg", "HS256" },
{ "typ", "JWT" }
};
var secToken = new JwtSecurityToken(headers, payload);
var handler = new JwtSecurityTokenHandler();
// Token to String so you can use it in your client
var tokenString = handler.WriteToken(secToken);
Generated token looks like: xxxx.yyyy
When I pass the same value on the page: jwt.io
and generate token, the format of two first parts are the same: xxxx.yyyy.(zzzz)
but on the page .zzzz
is generated because there is something like:
VERIFY SIGNATURE
HMACSHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
) secret base64 encoded
How and where should I add this part of signature?