Token not regenerating in subsequent execution


#1

i’m using zoom api tokens and set exp as 60 seconds where as my code will complete in less than 20 seconds.

I run my code in repeated intervals of 5 mins and observed that token is not regenerated and getting 401 error.

i believe that my token is generated only once though am executing complete code in subsequent runs.

is there anyway to flush the token after completing or ways to regenerate token or refresh in next run?

 

 


#2

Hi Rakesh, 

What authentication method are you using, OAuth or JWT?

Thanks


#3
Hi Michael,

Thanks for the response 

using JWT as below with payload - exp set to 60 seconds

token = jwt.encode(payload, SECRET, algorithm='HS256', headers=header\_zoom)
header\_zoom\_api = { 'Authorization': 'Bearer %s' % token }
response = requests.get(url,headers=header\_zoom\_api)

regardless of any number of executions, i get token only for 60 seconds. Is there anyway to get new token per execution ( 5 mins )

#4

Hi Rakesh, 

Based on your code, you can call the JWT anytime to generate a new token or set the **exp (expiration time) **value to more than 60 seconds. 

https://devdocs.zoom.us/docs/json-web-token-jwt

Thanks


#5

My code runs for about 5 to 10 seconds to get zoom rooms and do some math on it. I also ran my code in for loop and observed token generated in first iteration and subsequent iterations is same, regardless of calling token generating code in every iteration and gets 401 after 60 seconds from first iteration.


#6

Hi Rakesh, 

With JWT there is not a secure built in way to get a new token every time.  If you are looking for a more secure way to get a new or refresh tokens, then I suggest using OAuth flow, otherwise you can set the exp time to more than 60 seconds. 

Thanks


#7

Thanks Michael,

can you please provide any documentation for Oauth. can i use my KEY and SECRET to run with Oauth or is something i need to request new creds?

 

Thanks for the help


#8

Hi Rakesh, 

To use OAuth you will need to register your app within our new Marketplace. Here is a getting started guide for marketplace. 

Here is a step by step guide for OAuth as well - https://devdocs.zoom.us/docs/oauth-step-by-step.