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