Create Meeting from ASP.Net Page with OAuth Example

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

Thanks
tarun

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.

Here is a link to our Docs:
https://developers.zoom.us/docs/internal-apps/#use-account-credentials-to-get-an-access-token

Cheers,
Elisa

Hi Elisa,

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”);

        RestResponse response = client.Execute(request);
        Label1.Text = response.Content;

I refer the code from the given link below, but the token is not generating, it will shift to zoom

Request to help

Best Regards
Tarun

Sorry for the last response, but I am able to generate the token, request to check and confirm

https://mpmilaap.in/Create?code=qoWZSLAuLi7SrnMGQf-QLmQlCYmksPReA

Now where I need to pass it with Client Secret

Thanks

hey @milaapmp
Could you please confirm if you are trying to migrate to Server to Server Oauth or Just OAuth admin level app?

Hi, As I just want to create and manage meetings from my portal as I was using JWT then I was able to create meetings from my portal.

I need that

Thanks

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