I am having an issue with token, the error is invalid token.
Please help.
string key = "MY_Key";
var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
var credentials = new Microsoft.IdentityModel.Tokens.SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
var header = new JwtHeader(credentials);
var payload = new JwtPayload
{
{ "iss", "my_API"},
{ "iat", DateTimeOffset.Now.ToUnixTimeSeconds() },
{ "exp", DateTimeOffset.Now.ToUnixTimeSeconds() + 1400 },
};
var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();
var tokenString = handler.WriteToken(secToken);
Console.WriteLine(tokenString);
var token = handler.ReadJwtToken(tokenString);
Console.WriteLine(token.Payload.First().Value);
RestClient client = new RestClient();
client.BaseUrl = new Uri("https://api.zoom.us/v2");
RestRequest request = new RestRequest("/users", Method.GET);
request.AddHeader("Authorization", "Bearer " + tokenString.ToString());
request.AddHeader("User-Agent", "Zoom-api-Jwt-Request");
request.AddHeader("Content-Type", "application/json");
var response = client.Execute(request);
Console.Write(response.StatusCode);
Actually I’m testing with the JWT token that you provided me on my app JWT dashboard, this JWT token need to be necessary to know if the authorization is granted. And this one did not work either
Thanks - I’ll give it a go, and I really do appreciate your reply.
But I’m using the JWT as created by the Zoom page, so surely Zoom will include any params that Zoom requires? I’m not creating the JWT using my own code (yet).
If my own JWT code works, I’ll update you here.
Either:
the Zoom page is giving me a bad JWT token, or…
the Zoom API is incorrectly rejecting my JWT token