We are using JWT without any issues as the JWT is going to deprecated so we need to shift to OAuth, I am using the following code
var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var now = DateTime.UtcNow;
var apiSecret = “My Secreat Key”;
byte symmetricKey = Encoding.ASCII.GetBytes(apiSecret);
var tokenDescriptor = new SecurityTokenDescriptor
{
Issuer = "My Issuers Code",
Expires = now.AddSeconds(300),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256),
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);
var client = new RestClient("https://api.zoom.us/v2/users/milaapmp@gmail.com/meetings");
var request = new RestRequest("", Method.Post);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(new { topic = "Meeting Topic", duration = "10", start_time = "2023-04-30T18:20:00", type = "2" });
request.AddHeader("authorization", String.Format("Bearer {0}", tokenString));
RestResponse restResponse = client.Execute(request);
HttpStatusCode statusCode = restResponse.StatusCode;
int numericStatusCode = (int)statusCode;
var jObject = JObject.Parse(restResponse.Content);
Host.Text = (string)jObject["start_url"];
Join.Text = (string)jObject["join_url"];
Code.Text = Convert.ToString(numericStatusCode);
Can I use the same code just change the OAuth Client Key and Secret or any changes, If you have any example of sample code request to share
Hi @milaapmp
Thanks for reaching out to us! I am happy to help here!
The only thing that you need to change is the way yo generate your token.
For the JWT app, you use your API key and secret to generate a JWT token.
In the case of the Server to Server oauth app, you will need to make a post request to our Oauth endpoint using your client ID, client secret, and account ID, to get the access_token.
Then that token will be used in the same way that you are currently using it.
Thanks for response, I have used the code to generate the token.
var client = new RestClient(“Sign In | Zoom”);
var request = new RestRequest(“”, Method.Post);
request.AddHeader(“Authorization”, “HSrRBUOaUTbUL6bV1UXKTGXvgKem5PY2”);
Hey @milaapmp
So your best choice here would be to user our Server to Sever OAuth app
The only thing that changes is the token generation (the API calls will remain the same)
With the JWT app type you use your API key and Secret to create a JWT token.
With the Server to Server OAuth endpoint, you will use the credentials associated with your app (account ID, client ID and client Secret) to request an access_token to our OAuth endpoint
Here’s a helpful post on how to generate access tokens using Postman
I have created the OAuth App in the panel ,
Using the following ASP.Net code , I am not able to get the token , can you help me out where I am missing, I followed the steps from documentation, also test with postman
Thanks
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public async Task<string> CreateMeeting()
{
// Step 1: Get an access token
var accessToken = await GetAccessToken();
if (string.IsNullOrEmpty(accessToken))
{
// Handle error when unable to retrieve the access token
return "Failed to retrieve access token";
}
// Step 2: Create a meeting
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var request = new
{
topic = "Sample Meeting",
type = 2, // Scheduled meeting
start_time = DateTime.UtcNow.AddMinutes(10).ToString("yyyy-MM-ddTHH:mm:ssZ"), // Start time in UTC
duration = 60, // Duration in minutes
timezone = "America/Los_Angeles",
settings = new
{
join_before_host = true,
mute_upon_entry = true,
auto_recording = "cloud"
}
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(request);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var createMeetingUrl = $"{BaseUrl}/users/me/meetings";
var response = await httpClient.PostAsync(createMeetingUrl, content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
// Parse the JSON response to get the meeting details
// You can retrieve the join URL, meeting ID, and other information from the response
return result;
}
// Handle error when unable to create the meeting
return "Failed to create meeting";
}
private async Task<string> GetAccessToken()
{
var httpClient = new HttpClient();
var request = new
{
grant_type = "client_credentials",
client_id = ClientId,
client_secret = ClientSecret
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(request);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var tokenUrl = "https://zoom.us/oauth/token";
var response = await httpClient.PostAsync(tokenUrl, content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
dynamic jsonResult = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
return jsonResult.access_token;
}
return null;
}
Hi @milaapmp
Thanks for reaching out to us!
It looks like you are passing the wrong grant_type when generating your access_token,.
Make sure that the grant_type is account_credentials instead of client_credentials
Hi there i create C# application and i configer Client ID, Client Secret in me application, and i also have redirect url. and this is final look of request to authorize use (step1): var authorizeUrl = $“Error - Zoom”; but is whill not working i get whole html code if sign in pageof zoomauthorize in my response body. Note i call a request using swagger
Hi @zainnabbas.ibs
Thanks for reaching out to us.
It looks like you are using an Oauth app for authorization and to generate your access token.
Here is a link to our Docs:
We have created a page with all OAuth feature http://mpmilaap.in.net/zoomtest
This is a test link where we are click on the create button it will move to Zoom page, after login it will back with token and create the meeting successfully, but it will accept our registered zoom id only, other will not work
Can you help me that once we click on the create button on the given URL , it will create the meeting link without Zoom Login,
Hi @milaapmp
Thanks for reaching out to us.
If you want users outside of your account to use your app, you will need to publish your app in the Zoom Marketplace
Hi my code is following to create meeting using zoom from asp.net c#
public async Task CreateMeeting()
{
// Step 1: Get an access token
var accessToken = await GetAccessToken();
if (string.IsNullOrEmpty(accessToken))
{
// Handle error when unable to retrieve the access token
return "Failed to retrieve access token";
}
// Step 2: Create a meeting
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var request = new
{
topic = "Sample Meeting",
type = 2, // Scheduled meeting
start_time = DateTime.UtcNow.AddMinutes(10).ToString("yyyy-MM-ddTHH:mm:ssZ"), // Start time in UTC
duration = 60, // Duration in minutes
timezone = "America/Los_Angeles",
settings = new
{
join_before_host = true,
mute_upon_entry = true,
auto_recording = "cloud"
}
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(request);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var createMeetingUrl = $"{BaseUrl}/users/me/meetings";
var response = await httpClient.PostAsync(createMeetingUrl, content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
// Parse the JSON response to get the meeting details
// You can retrieve the join URL, meeting ID, and other information from the response
return result;
}
// Handle error when unable to create the meeting
return "Failed to create meeting";
}
private async Task<string> GetAccessToken()
{
var httpClient = new HttpClient();
var request = new
{
grant_type = "account_credentials",
client_id = ClientId,
client_secret = ClientSecret
};
var json = Newtonsoft.Json.JsonConvert.SerializeObject(request);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var tokenUrl = "https://zoom.us/oauth/token";
var response = await httpClient.PostAsync(tokenUrl, content);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
dynamic jsonResult = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
return jsonResult.access_token;
}
return null;
}
But it showing error " The request was aborted: Could not create SSL/TLS secure channel."
when hit this " await httpClient.PostAsync" while creating token.
what is the solution for this
kindly help
Hi @dibakar.info05
I have not seen this error myself.
Could you please try generating an access token with postman and making an API call to make sure that this is not an issue on our end?