# Can't create meeting by using an access token(client\_credentials) for server-to-server oauth type

**URL:** <https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791>\
**Category:** Meetings\
**Created:** [August 7, 2022, 7:51am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791 "2022-08-07T07:51:12Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [August 7, 2022, 7:51am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/1 "2022-08-07T07:51:12Z")

</div>

Dears,  
Hope to get your help.

**API Endpoint(s) and/or Zoom API Event(s)**  
_[https://api.zoom.us/v2/users/{my-user-id}/meetings](https://api.zoom.us/v2/users/%7Bmy-user-id%7D/meetings)_

**Description**  
_I’m trying to create meeting by using Zoom meeting Apis_  
_After getting an access token by using grant type of client\_credentials and using client id and client secret of server-to-server oauth app type. By this way I got an access token_  
“But when trying to use this access token at create meeting api I got the error message the mentioned below”

**Error?**  
_Invalid api key or secret._

**How To Reproduce**  
_Steps to reproduce the behavior:_  
_1. [https://api.zoom.us/v2/users/{my-user-id}/meetings](https://api.zoom.us/v2/users/%7Bmy-user-id%7D/meetings)_  
_2. client credentials and server to server oauth app type_  
_3. {  
“code”: 200,  
“message”: “Invalid api key or secret.”  
}_

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 8, 2022, 1:47pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/2 "2022-08-08T13:47:15Z")

</div>

Hi @xpe

Hope you are doing great! I am happy to help here!  
This looks like a credentials issue.  
Please refer to the following thread were I helped other developers with a similar issue:

> [@"Invalid api key or secret" error in Server-to-Server OAuth app](https://devforum.zoom.us/t/invalid-api-key-or-secret-error-in-server-to-server-oauth-app/72579/15):
>
> After some debugging together, we figured it out @beirne !!! Here are some steps to debug and fix this issue if you are getting the same error Make sure that you have the right permissions enabled in your account to be able to user the Server-to-Server OAuth app, you can do so in the Web Portal, by going to User Management \> Roles \> Role Settings \> Advanced features (this can only be done by an Administrator or the Owner of the account) Make sure tha…

Hope this helps 🙂  
Elisa

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [August 10, 2022, 6:21am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/3 "2022-08-10T06:21:18Z")

</div>

Hi @elisa.zoom ,

I did made the required changes mentioned above to the owner role, However, still facing the same issue.

 ![Zoom Issue](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/f/f/ff0a4e69112a201daa67bf434704b3ef361ad0fa.png)

![Zoom Issue2](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/3/c/3c206fe4aaf960a519011e6f8d8db9a20415e5c1.png)

 ![Zoom Issue3](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/e/0/e0c2ccab63787fd072215834360e97e1fc450ea8.png)

Thank you.

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 10, 2022, 11:13am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/4 "2022-08-10T11:13:28Z")

</div>

Hi @xpe,  
Interesting.  
It might be the way you are making the request then.  
Feel free to refer to this post and let me know if it helps:

> [@How to user Server-to-Sever OAuth app with Postman](https://devforum.zoom.us/t/how-to-user-server-to-sever-oauth-app-with-postman/70848):
>
> How to use our Server-to-Server OAuth with Postman? As some of you might be aware of, our JWT app is being deprecated by June 2023 and we encourage you to migrate to the newly introduced [Server-to-Server OAuth App](https://marketplace.zoom.us/docs/guides/build/server-to-server-oauth-app) That being said, here is a quick and simple guide on how to use or new app with Postman As stated in our documentation here: This new app type facilitates OAuth-authenticated requests between servers without end-user involvement. And this grant type enable your private server a…

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [August 11, 2022, 12:33pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/5 "2022-08-11T12:33:12Z")

</div>

Hi @elisa.zoom ,

Thanks for your help, that URL fixes my issue.  
But I have another issue when trying to join meeting through Meeting Web SDK, Using sdk jwt type.  
After generating SDK JWT token as a signature(by using SDK key and SDK secret that generated from SDK type app ) and pass this signature to join meeting function with the other parameters, I got this error( errorCode: 3712, errorMessage: “Signature is invalid.”, method: “join”, result: “Invalid signature.”, status: false ).

 ![SDK JWT Token](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/9/4/94687b8f2d17e6bc8a3275782e8645ecc31a77b4.png)

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [August 11, 2022, 4:32pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/6 "2022-08-11T16:32:59Z")

</div>

@xpe ,

Have you tried to generate the signature with our sample? I’ve found manually entering the output from our sample app, then comparing signatures helps isloate the root cause.

> **[GitHub - zoom/meetingsdk-sample-signature-node.js: Generate a signature to...](https://github.com/zoom/meetingsdk-sample-signature-node.js)**
>
> Generate a signature to Start and Join Meetings and Webinars with the Zoom Meeting SDKs. - GitHub - zoom/meetingsdk-sample-signature-node.js: Generate a signature to Start and Join Meetings and Web...

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 11, 2022, 6:21pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/7 "2022-08-11T18:21:33Z")

</div>

Thanks for chiming in @donte.zoom  
I appreciate your help!

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [October 20, 2022, 9:40am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/9 "2022-10-20T09:40:43Z")

</div>

Hello again,  
I can confirm from the sample above that I have something wrong in my signature. But I really cannot figure it out.

This signature is generated with my code:

> [REDACTED]

And this one is generated with the sample:

> [REDACTED]

both signatures are for the same meeting number.

The generated tokens are so close even in time but the one from the sample is working and the one generated with my app is not working and getting me Invalid Signature error!

I don’t know where the problem is.  
I’m using C# and JwtSecurityTokenHandler

and creating the token as follows:

```auto
meetingNumber = "xxxxxxxxxx";

            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new[]
                {   
                    new Claim("sdkKey", sdkKey),
                    new Claim("mn", meetingNumber),
                    new Claim("role", role),
                    new Claim("iat", ts.ToString()),
                    new Claim("exp", expTs.ToString()),
                    new Claim("appKey", sdkKey),
                    new Claim("tokenExp", expTs.ToString())
                }),

                //Expires = now.AddMinutes(Convert.ToInt32(120)),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey),SecurityAlgorithms.HmacSha256Signature)
            };

            var stoken = tokenHandler.CreateToken(tokenDescriptor);

```

Appreciate if you can help.  
Thanks and regards

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 20, 2022, 11:00am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/10 "2022-10-20T11:00:31Z")

</div>

@xpe ,  
It looks like the `iat` value is invalid. You can use [https://jwt.io/](https://jwt.io/) to decode your token and verify the values for the payload properties are correct:

 ![9f439d0070ab1b6c2e5d7c8a7d4341674b330d45](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/9/6918000104a9aedb242f6a944c1abb62702faf48.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/f/d/fd2165dcaa0fe0b74e24b35dbdb78b4037ebdb57.png)

For reference, here is our help documentation generating an SDK JWT token:

[https://marketplace.zoom.us/docs/sdk/native-sdks/auth/#generate-the-sdk-jwt](https://marketplace.zoom.us/docs/sdk/native-sdks/auth/#generate-the-sdk-jwt)

# Also, please do not post your token on the Forum as it is considered PII.

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [October 23, 2022, 7:14am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/11 "2022-10-23T07:14:55Z")

</div>

Hello Donte.Zoom,

Thanks for your replay.  
The invalid date is appearing just because of the double quotes. Actually, the value you are referring to, is in the working signature.  
I tried by both, the double quotes and without but the result is the same.

Thanks

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [October 24, 2022, 7:05am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/12 "2022-10-24T07:05:26Z")

</div>

After investigation, I can confirm that the problem is in the way I’m using the signature.  
I’m revising it. appreciate if there is any updated code that is in c# or .Net for SDK signature generation.

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [October 24, 2022, 7:39am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/13 "2022-10-24T07:39:59Z")

</div>

I was able to find the solution for the problem.  
I was treating apiSecret as base64 string and converting it to byte using:  
`var symmetricKey = Convert.FromBase64String(apiSecret);`

And this was the issue.  
Using ASCII encoding instead solved the problem:  
`var symmetricKey = Encoding.ASCII.GetBytes(apiSecret);`

Thanks for your time and support.

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 24, 2022, 6:22pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/14 "2022-10-24T18:22:43Z")

</div>

Awesome to hear you were able to resolve the issue, @xpe! I will make sure to get this caveat documented and will share it here. In the meantime, can you share the entire code snippet of the working solution for other community members’ benefit?

---

<div class="post-metadata">

**Author:** ![xpe](https://avatars.discourse-cdn.com/v4/letter/x/43a26b/32.png) [@xpe](https://devforum.zoom.us/u/xpe)\
**Post date:** [October 25, 2022, 7:02am UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/15 "2022-10-25T07:02:37Z")

</div>

Here is a complete signature generation code using `c#` and `System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler`  
hopefully it would help others:

```auto

public string GenerateSdkJwtToken(string apiKey, string apiSecret, string meetingNumber, int role)
        { 
            //convert secret to byte[]. This is the correct way.
            var symmetricKey = Encoding.ASCII.GetBytes(apiSecret);
            var tokenHandler = new JwtSecurityTokenHandler();
            //don't automatically add nbf to the generated token.
            tokenHandler.SetDefaultTimesOnTokenCreation = false;
            //set issue date and expiration.
            var now = DateTime.UtcNow;
            //get epoch seconds.
            long tss = ToTimestamp(now.ToUniversalTime()) - 30;
            long expTs = tss + 60 * 60 * 2; //add a reasonable value for expiration time.
            //token payload
            var objTokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new[]
                {   
                    new Claim("sdkKey", sdkKey),
                    new Claim("mn", meetingNumber),
                    new Claim("role", role.ToString()),
                    new Claim("iat", tss.ToString()),
                    new Claim("exp", expTs.ToString()),
                    new Claim("appKey", sdkKey),
                    new Claim("tokenExp", expTs.ToString())
                }),
                //sign the token using Sha256
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey),SecurityAlgorithms.HmacSha256Signature)
            };

            var sTokenObj = tokenHandler.CreateToken(objTokenDescriptor );
            var strJwtToken = tokenHandler.WriteToken(sTokenObj);
            //here is your final token.
            return strJwtToken;
        }
//There are several way you can get Epoch seconds. Here is one method 
public static long ToTimestamp(DateTime value)
        {
            TimeSpan t = value - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            long secondsSinceEpoch = (int)t.TotalSeconds;
            return secondsSinceEpoch;
        }

```

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [October 25, 2022, 12:38pm UTC](https://devforum.zoom.us/t/cant-create-meeting-by-using-an-access-token-client-credentials-for-server-to-server-oauth-type/73791/16 "2022-10-25T12:38:31Z")

</div>

Awesome, @xpe! Thank you so much for sharing your solution with the community. It will be greatly beneficial to others encountering the same issue.
