Hey @kellyjandrews ,
I’m sure on using API and API secret, so what will be the other possible reason.
Also I have used JWT token which is available in Video SDK APP, please refer below image
Code to generate the token is as below, using .Net Core C#.
using System.IdentityModel.Tokens.Jwt;
public string GetVideoSDKAPIToken(string apiKey, string apiSecret, int accessTokenValidityInMinutes = 120, int tokenValidityInMinutes = -1)
{
DateTime now = DateTime.UtcNow;
if (tokenValidityInMinutes <= 0)
{
tokenValidityInMinutes = accessTokenValidityInMinutes;
}
int tsNow = (int)(now - new DateTime(1970, 1, 1)).TotalSeconds;
int tsAccessExp = (int)(now.AddMinutes(accessTokenValidityInMinutes) - new DateTime(1970, 1, 1)).TotalSeconds;
int tsTokenExp = (int)(now.AddMinutes(tokenValidityInMinutes) - new DateTime(1970, 1, 1)).TotalSeconds;
return GenrateVideoSDKAPIToken(apiSecret, new JwtPayload
{
{ "iss", apiKey },
{ "exp", tsAccessExp },
{ "iat", tsNow }
});
}
public static string GenrateVideoSDKAPIToken(string apiSecret, JwtPayload payload)
{
// Create Security key using private key above:
// note that latest version of JWT using Microsoft namespace instead of System
var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(apiSecret));
// Also note that securityKey length should be >256b
// so you have to make sure that your private key has a proper length
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
// Finally create a Token
var header = new JwtHeader(credentials);
var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();
// Token to String so you can use it in your client
return handler.WriteToken(secToken);
}
Code to call a API,
var client = new RestClient(_zoomConfiguration.Zoom_Base_URL + "/videosdk/sessions/" + sessionid + "/events");
var request = new RestRequest(Method.PATCH);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", token);
request.AddParameter("application/json", json, ParameterType.RequestBody);
IRestResponse response = await client.ExecuteAsync(request);
responseObj = JsonConvert.DeserializeObject<CallOutDTO>(response.Content);