401 Unauthorized: "{"code":124,"message":"Invalid access token."}"

API Endpoint(s) and/or Zoom API Event(s)
Zoom Api Url:
https://api.zoom.us/v2/users/<my_user_id>/meetings

Oauth Api Url :
https://zoom.us/oauth/token?grant_type=account_credentials&account_id=<my_account_id>

Description
I am using zoom api to create zoom meeting. And for the authorization I am using Bearer Token.

I am using Server-to-Server OAuth App api to fetch the bearer token. The api works fine. But I found that after some time (not know exactly when) the create meeting api started getting failed with error as: “{“code”:124,“message”:“Invalid access token.”}”.

Whenever my token expires, I am fetching the new token. But same problem occurring with new token also. That is initially I am able to create meeting but after sometimes I started getting Token Invalid error.

Error?
“{“code”:124,“message”:“Invalid access token.”}”

Below is the screenshot of my application logs. Showing when I have created new token and when started getting error.

Hi @aayush.jain ,

Server to Server tokens expire after 1 hour, so you’ll need to request a new one each time. Is the token expiring before the hour?

Let us know!

Yes, I am aware of 1 hour expiry. But I observed that I started getting issue after around 30 min of creation time.( Which means there are at least 30min remaining for the expiry).
Also, In case of expiry we gets “{“code”: 124,“message”: “Access token is expired.”}” error message.
So, I guess token expiry is not the case.
I also tried the same via postman app. There also I am getting same error after around 30min.

@aayush.jain

When you see the error, are you requesting a specific endpoint or do they all fail when they were previously working?

I am using only two api’s one for creating meeting and one for deleting meeting.

  1. https://api.zoom.us/v2/users/<my_user_id>/meetings
  2. https://api.zoom.us/v2//meetings/

Both the api’s are failing . In some cases I found that the calls failed after 20min also, with the same error message.

@aayush.jain

Are you by chance generating a secondary token before you make this API call and using an older token?

There really shouldn’t be any reason why a token is invalid within 20 minutes if it is a server to server token.

I guess yes, I am generating another token while using first. And tested same behaviour with postman also. There also older one became invalid after generating new. But things were not same when I was using JWT token.
I will fix this and update.

Hi I am facing the same issue, are you saying that once a new token is generated we are not able to use the old one even its not expired yet? If that’s the case how can we retrieve the current valid token on different API requests?

Hi @amonasalama, you are using OAuth flow (Online or Offline)?

If you are using Offline then you need to store access_token and refresh_token in side DB. Once access_token expired you need to regenerate new access and refresh token using old refresh token and then in the response you have also refresh and access tokens so keep updating both in db. Refresh token expiry will be in 15 years.

Hi @freelancer.nak don’t know how to get this information I am using server-to-server auth and I can’t see anything on the documentation about that

@amonasalama @aayush.jain, Please watch Zoom OAuth sessions → P1 and P2.

Thankyou @rarev , The issue is due to I am generating another token while using first.

Hi @amonasalama I solved my issue by storing token and its expiry in a cache. And I am regenerating only when it expires.

To regenerate token you need to call below oauth api with Basic Auth credentials . Same is mentioned at : https://marketplace.zoom.us/docs/guides/build/server-to-server-oauth-app/#use-account-credentials-to-get-an-access-token