124 Error when running code on Server. Works fine on my Laptop

Description
I wrote python code to get all currently scheduled Meetings. When I tested it on my Laptop it worked fine and I got the list of scheduled Meetings. But after hosting my code on a server I zoom returns {'code': 124, 'message': 'Invalid access token.'}

Error
{'code': 124, 'message': 'Invalid access token.'}

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

Which Endpoint/s?

https://api.zoom.us/v2/users/{userId}/meetings?type=upcoming

How To Reproduce (If applicable)
My python Code:

import jwt, requests, json
from time import time

API_Key = 'XXXXXXXXXXXXXXXXXX'
API_SEC = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'

def generateToken():
    token = jwt.encode(
        
        # Create a payload of the token containing 
        # API Key & expiration time
        {'iss': API_Key, 'exp': (time() + 5000)},
          
        # Secret used to generate token signature
        API_SEC,
          
        # Specify the hashing algorithm
        algorithm='HS256'
    )
    return token

def getMeetings():
    headers =  {'authorization': 'Bearer %s' % generateToken(),
               'content-type': 'application/json'}
    r = requests.get(
         f'https://api.zoom.us/v2/users/{userId}/meetings?type=upcoming', 
       headers=headers)
    y = json.loads(r.text)
    return y

Hey @fff,

Thank you for reaching out to the Zoom Developer Forum. Please send an email to developersupport@zoom.us with a link to this thread. In that email, please provide an example of a token that your server generated.

I’ll investigate further from there.

Thanks,
Max

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