# I am getting 401 error on an inconsistent basis by calling Zoom API, using JWT for server-server authentication

**URL:** <https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135>\
**Category:** API and Webhooks\
**Created:** [November 11, 2021, 12:37pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135 "2021-11-11T12:37:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniyal\_Khan](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/daniyal_khan/32/17069_2.png) [@Daniyal\_Khan](https://devforum.zoom.us/u/Daniyal_Khan)\
**Post date:** [November 11, 2021, 12:37pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/1 "2021-11-11T12:37:50Z")

</div>

## Using this template helps us debug your issues more effectively 🙂

**Description**  
I am calling Zoom APIs for creating, updating, and deleting zoom meetings. I am calling Zoom APIs via [axios](https://www.npmjs.com/package/axios) library and I am using the following API request

```auto
const { status, data } = await axios.post(
      `https://api.zoom.us/v2/users/${email}/meetings`,
      meetingData,
      {
        params: {
          status: 'active',
        },
        headers: {
          Authorization: `Bearer ${token}`,
          'content-type': 'application/json',
        },
        withCredentials: true,
      }
    );

```

This the test application ID (‘MY6HUKesQv6qTwwmbUCrtA’) using JWT in order for me to perform server-server integration. Sometimes, I get 401 error in calling Zoom API calls for example when I call delete endpoint for deleting zoom meetings, I get 401 error consistently but when I call another API endpoint namely; get request for Zoom, then it works without any issues and interestingly, I can call delete API without any issues

**Error**  
401 error on an inconsistent basis when calling Zoom APIs.

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

**Which Endpoint/s?**  
DELETE /meetings/{meetingId}  
GET /meetings/{meetingId}

**How To Reproduce (If applicable)**  
Steps to reproduce the behavior:

1. Request URL / Headers (without credentials) / Body
2. See error

**Screenshots (If applicable)**

 ![jwt error](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/d/e/deea7c8dd715644e19e7befdf36f44f32ecb976a.png)

**Additional context**  
Add any other context about the problem here.

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [November 11, 2021, 9:32pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/2 "2021-11-11T21:32:14Z")

</div>

Hi @Daniyal_Khan ,

Happy to help!

> [@Daniyal\_Khan](#):
>
> Sometimes, I get 401 error in calling Zoom API calls for example when I call delete endpoint for deleting zoom meetings, I get 401 error consistently but when I call another API endpoint namely; get request for Zoom, then it works without any issues and interestingly, I can call delete API without any issues

Are you saying that when you make a GET request first and _then_ a DELETE request, it works. But if you _just_ call the DELETE request it doesn’t work?

Thank you,  
Gianni

---

<div class="post-metadata">

**Author:** ![Daniyal\_Khan](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/daniyal_khan/32/17069_2.png) [@Daniyal\_Khan](https://devforum.zoom.us/u/Daniyal_Khan)\
**Post date:** [November 12, 2021, 11:20am UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/5 "2021-11-12T11:20:04Z")

</div>

Hi @gianni.zoom I figured out the issue, the problem is in the following line of code

```auto
const payload = {
  iss: process.env.ZOOM_JWT_API_KEY,
  exp: Math.floor(Date.now() / 1000) + 60 * 60, //*expiry is set to one hour
};

```

now since I restarted my server every now and then due to the addition of new features, payload was created again leading to my misunderstanding of inconsistent API calls whereas it worked perfectly before.

Should I request for a refresh token after payload has expired or do I need to generate a separate payload for each API request

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [November 15, 2021, 8:36pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/6 "2021-11-15T20:36:16Z")

</div>

Hey @Daniyal_Khan,

Awesome! I’m glad to hear that you were able to resolve the issue.

When it comes to JWT, there actually isn’t a refresh token. Instead, you would want to regenerate the JWT token with a new expiration.

When it comes to an [OAuth App](https://marketplace.zoom.us/docs/guides/auth/oauth), you would wan to use the refresh token before the current access token expires otherwise the app will need to be reauthorized.

I hope that helps! Let me know if you have any questions.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![Daniyal\_Khan](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/daniyal_khan/32/17069_2.png) [@Daniyal\_Khan](https://devforum.zoom.us/u/Daniyal_Khan)\
**Post date:** [November 16, 2021, 4:24am UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/7 "2021-11-16T04:24:49Z")

</div>

Thanks @MaxM, I resolved the issue by issuing JWT token on each login with an expiry date equal to the expiry date of the session cookie itself. I copied zoom github repo that contained the code of Nodejs JWT and I forgot to regenerate the JWT token.

Regards,  
Daniyal Talat

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [November 17, 2021, 11:33pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/8 "2021-11-17T23:33:23Z")

</div>

Hey @Daniyal_Khan,

Awesome, I’m glad to hear that you were able to resolve the issue! Thanks for sharing what worked for you here.

I’ll go ahead and close this topic now but feel free to open a new topic if you encounter any further issues or questions.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![simran.na.sah](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/simran.na.sah/32/25767_2.png) [@simran.na.sah](https://devforum.zoom.us/u/simran.na.sah)\
**Post date:** [December 1, 2021, 6:10pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/9 "2021-12-01T18:10:07Z")

</div>

Hello,

I’m facing the similar issue while calling the GET/list of users api from Salesforce and the issue is inconsistent. When I hit the api the next minute after getting the error it works just fine without refreshing any token or stuffs.

Edit : I’m using OAuth App

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [December 6, 2021, 11:23am UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/10 "2021-12-06T11:23:14Z")

</div>

Hey @simran.na.sah,

Are you making many requests to the /oauth endpoint around the same time? If you continue to see this consistently, let us know.

Thanks,  
Will

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [January 5, 2022, 9:23pm UTC](https://devforum.zoom.us/t/i-am-getting-401-error-on-an-inconsistent-basis-by-calling-zoom-api-using-jwt-for-server-server-authentication/60135/11 "2022-01-05T21:23:56Z")

</div>

Closed on January 5, 2022, 9:23pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
