{"code":124,"message":"The Token can't be used before"} when trying to create a meeting using JWT

Description
I’m trying to schedule a zoom meeting by using JWT in C# ASP.NET. However, when I try to call below request URL the error pops up as,

Request Url: https://api.zoom.us/v2/users/{0}/meetings

Response :{“code”:124,“message”:“The Token can’t be used before Wed Sep 08 10:17:07 UTC 2021.”}

Error
Response :{“code”:124,“message”:“The Token can’t be used before Wed Sep 08 10:17:07 UTC 2021.”}

Which App Type (OAuth / Chatbot / JWT / Webhook)?
JWT

How To Reproduce (If applicable)

var client = new RestClient("https://api.zoom.us/v2/users/my_user_id/meetings");
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(new { topic = meetingDescription, duration = duration, start_time = startDateTime, type = 2 });
equest.AddHeader("authorization", String.Format("Bearer {0}", tokenString));

//Get Response
var restResponse = client.Execute(request);

Additional context
I have noticed that in the response headers Date is always few seconds behind the ValidFrom date of JWT token.

Hey @praveenag,

Thank you for reaching out to the Zoom Developer Forum. Please make sure that your server is using a UTC timezone when generating the JWT token and making the request.

If that doesn’t help, please send an email to developersupport@zoom.us with a link to this thread as well as the JWT token you’re seeing issues with.

Let me know if that helps.

Thanks,
Max

Hi @MaxM,

Thank you for your response. I have been able to resolve the issue by using below code posted by @k.krylov on How to create JWT token using REST api in c# to generate the JWT Token. Posting the code below,

public static string ZoomToken()
{
// Token will be good for 20 minutes
DateTime Expiry = DateTime.UtcNow.AddMinutes(20);

string ApiKey = ConfigurationManager.AppSettings["ClientIdJwt"];
string ApiSecret = ConfigurationManager.AppSettings["ClientSecretJwt"];

int ts = (int)(Expiry - new DateTime(1970, 1, 1)).TotalSeconds;

// Create Security key  using private key above:
var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(ApiSecret));

// length should be >256b
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

//Finally create a Token
var header = new JwtHeader(credentials);

//Zoom Required Payload
var payload = new JwtPayload
{
      { "iss", ApiKey},
      { "exp", ts },
};

var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();

// Token to String so you can use it in your client
var tokenString = handler.WriteToken(secToken);

      return tokenString;
}
1 Like

Awesome! Thanks for sharing your solution.

I’ll go ahead and close this topic now but feel free to open a new topic if you encounter any further issues or questions.

Max