# S2S OAuth Token invalid before 3600 seconds are over

**URL:** <https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858>\
**Category:** Meetings\
**Created:** [October 25, 2022, 9:35am UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858 "2022-10-25T09:35:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![frank.kiss](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@frank.kiss](https://devforum.zoom.us/u/frank.kiss)\
**Post date:** [October 25, 2022, 9:35am UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/1 "2022-10-25T09:35:59Z")

</div>

Hello,

from time to time it happens that a created S2S OAuth token becomes invalid and cannot be used anymore for API consumption before the 3600 seconds of validity are over.

Unfortunately I could not reproduce the problem yet when I was trying to in order to restrict it to a certain behavior of our API clients . But from a gut feeling it happens after this token has been used for creating/deleting users and/or creating/deleting meetings.

Does anyone have an idea what could be the problem, or even similar experiences?

Thanks  
Frank

---

<div class="post-metadata">

**Author:** ![david5](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/david5/32/40553_2.png) [@david5](https://devforum.zoom.us/u/david5)\
**Post date:** [October 25, 2022, 2:58pm UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/2 "2022-10-25T14:58:44Z")

</div>

Do you have multiple instances of your application running at the same time (e.g. in a clustered environment)? You might be running into the undocumented “feature” where the previous OAuth token is invalidated when you request a new one.

> [@Randomly receiving "Invalid access token" for Server-to-Server OAuth](https://devforum.zoom.us/t/randomly-receiving-invalid-access-token-for-server-to-server-oauth/74432/22):
>
> For posterity and anyone else who happens to run across this thread while scratching their head about how Server-to-Server OAuth works: Requesting a new Server-to-Server OAuth token invalidates the previous one. Zoom can increase the “index” count for your account, allowing you to request different tokens with different indexes that do not interfere with each other (i.e. requesting a token for index 1 doesn’t invalidate the token requested for index 2). The token index is specified in the call…

---

<div class="post-metadata">

**Author:** ![frank.kiss](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@frank.kiss](https://devforum.zoom.us/u/frank.kiss)\
**Post date:** [October 26, 2022, 8:10am UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/3 "2022-10-26T08:10:26Z")

</div>

Indeed, that’s the reason. I can now reproduce this behavior reliably.

However, I don’t get your linked solution to work. When I try to create a token and pass a token index like this:  
[https://zoom.us/oauth/token?grant\_type=account\_credentials&account\_id=XXXXXXXXXXXXXXXXXXXX&token\_index=1](https://zoom.us/oauth/token?grant_type=account_credentials&account_id=XXXXXXXXXXXXXXXXXXXX&token_index=1)

I get the error message 400: Invalid request : Maximum group number limit exceeded

Do you know how to get that solved?

---

<div class="post-metadata">

**Author:** ![frank.kiss](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@frank.kiss](https://devforum.zoom.us/u/frank.kiss)\
**Post date:** [October 26, 2022, 8:17am UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/4 "2022-10-26T08:17:20Z")

</div>

Ok, now it’s clear: [Server-to-Server OAuth: annoying token-invalidation](https://devforum.zoom.us/t/server-to-server-oauth-annoying-token-invalidation/72070)

ZOOM needs to increase the available number of token indexes manually in their backend, and it can be set to 3 max.

---

<div class="post-metadata">

**Author:** ![david5](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/david5/32/40553_2.png) [@david5](https://devforum.zoom.us/u/david5)\
**Post date:** [October 27, 2022, 3:27pm UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/5 "2022-10-27T15:27:45Z")

</div>

Yeah…it’s a pain. You have to pester Zoom to get the index limit increased. Sorry that wasn’t clear in my original post.

---

<div class="post-metadata">

**Author:** ![frank.kiss](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@frank.kiss](https://devforum.zoom.us/u/frank.kiss)\
**Post date:** [October 28, 2022, 8:27am UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/6 "2022-10-28T08:27:39Z")

</div>

At the moment kind of, yes. But the problem in fact is, that it is apparently not documented anywhere. When it is documented, you can take it into consideration.

Then I see two options:

1. You create a new token every time you want to call any API. This is surely not how it should be done because the token is valid for one hour, and it would decrease performance of your app.

2. You save the token somewhere in your DB together with a valid-to timestamp. Then you can reuse it every time you need it, and create a new one when the valid-to moment has been reached.

I think I will go for the second option.

---

<div class="post-metadata">

**Author:** ![david5](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/david5/32/40553_2.png) [@david5](https://devforum.zoom.us/u/david5)\
**Post date:** [October 28, 2022, 3:29pm UTC](https://devforum.zoom.us/t/s2s-oauth-token-invalid-before-3600-seconds-are-over/77858/7 "2022-10-28T15:29:45Z")

</div>

FWIW, we did option #2 as well, only we didn’t store it in the DB, we used AWS Secrets Manager. We also wrote a scheduled Lambda that would rotate the token every 50 minutes
