Create Meeting Unauthorized

Description
I am trying to create a meeting using C# / RestSharp, but I keep receiving an ‘Unauthorized’ response, with content of ‘"{“code”:124,“message”:“Invalid access token.”}"’. However, if I run the same code to retrieve a list of users, the response comes back without any problems?!

Error
Unauthorized, Code 124, Message “Invalid Access Token”

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

Which Endpoint/s?
Create Meeting

How To Reproduce (If applicable)
Steps to reproduce the behavior:
This doesn’t work:

var tokenHandler = new JwtSecurityTokenHandler();
DateTime expiry = DateTime.UtcNow.AddMinutes(5);
string apiSecret = “API_SECRET”;
string apiKey = “API_KEY”;
int ts = (int)(expiry - new DateTime(1970, 1, 1)).TotalSeconds;

var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(apiSecret));

var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
var header = new JwtHeader(credentials);

var payload = new JwtPayload
{
{ “iss”, apiKey},
{ “exp”, ts },
};

var securityToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();
var tokenString = handler.WriteToken(securityToken);

RestClient client = new RestClient();
client.BaseUrl = new Uri(“http://api.zoom.us/v2/users/me/meetings”);
RestRequest request = new RestRequest(Method.POST);

request.AddHeader(“content-type”, “application/json”);
request.AddHeader(“authorization”, String.Format(“Bearer {0}”, tokenString));

var data = “{“topic”: “Test Meeting”,“type”: 2,“start_time”: “2020-12-11T10:00”,“duration”: 60,“timezone”: “Europe/London”,“password”: “abcd”,“agenda”: “Testing Meeting”}”;

request.AddParameter(“application/json”, data, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

This does:

var tokenHandler = new JwtSecurityTokenHandler();
DateTime expiry = DateTime.UtcNow.AddMinutes(5);
string apiSecret = “API_SECRET”;
string apiKey = “API_KEY”;
int ts = (int)(expiry - new DateTime(1970, 1, 1)).TotalSeconds;

var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(apiSecret));

var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
var header = new JwtHeader(credentials);

var payload = new JwtPayload
{
{ “iss”, apiKey},
{ “exp”, ts },
};

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

var tokenString = handler.WriteToken(securityToken);

RestClient client = new RestClient();
client.BaseUrl = new Uri(“https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1”);
RestRequest request = new RestRequest(Method.GET);

request.AddHeader(“content-type”, “application/json”);
request.AddHeader(“authorization”, String.Format(“Bearer {0}”, tokenString));

IRestResponse response = client.Execute(request);

Hi @matt-clickinon,

In your request URL, can you replace me with the user (userId or email) who you’re creating the meeting for? Our Create Meeting endpoint doesn’t support the me context as it’s a user-level endpoint.

Try making this change and let me know if this resolves the error.

Thanks,
Will

Hi @will.zoom ,

I tried it both with “me” and with both the user email addresses registered in our account.

Thanks

Matt

Hey @matt-clickinon,

Thank you for providing additional information. Are you able to provide a log of the endpoint, request body, and you are using when you encounter an Unauthorized response?

Thanks,
Max