Could not load type 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken' from assembly 'System.IdentityModel.Tokens.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Claims;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel.Tokens;
{
public class getToken
{
public string getJWTToken(string apiKey, string secret)
{
string tokenCreationTime = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
//Your payload
var claims = new[]
{
new Claim(/iss/,apiKey),
new Claim(/iat/, tokenCreationTime)
};
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(secret);
string base64String = Convert.ToBase64String(bytes);
var key = new SymmetricSecurityKey(Convert.FromBase64String(base64String));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
issuer: apiKey,
claims: claims //,
//expires: DateTime.Now.AddHours(1), // Adjust as needed
signingCredentials: creds
);
return tokenString;
}
}
}
and the code i used in x++ is
internal final class JWTGenerate
{
public static void main(Args _args)
{
JWT.getToken getToken;
getToken = new JWT.getToken();
str api = '********************',
secret = '********************';
info(strFmt(/%1/, token));
}