Error Code 124 for Python JWT API

Description
I’m trying to put together some Python code that, when run, will end a meeting via the API. I’m currently using JWT, have the app set up on Zoom’s site, and when running the code, have the api key and secret in their appropriate places in the code.

THE CODE:


import jwt
import requests
import datetime
from datetime import timedelta
import http.client

#Variables
api_key = ‘INSERT KEY HERE’
api_sec = ‘INSERT SECRET HERE’

def generateToken():
token = jwt.encode(
{“iss”: api_key, “exp”: datetime.datetime.now() + datetime.timedelta(hours=1)},
api_sec,
algoritm=‘HS256’
).decode(‘utf-8’)

return token

conn = http.client.HTTPSConnection(“api.zoom.us”)

payload = “{\“action\”:\“end\”}”

headers = {
‘authorization’: “Bearer %s” % generateToken,
‘content-type’: “application/json”
}

conn.request(“PUT”, “/v2/meetings/INSERT MEETING HERE/status”, payload, headers=headers)

res = conn.getresponse()
data = res.read()

print(data)


END CODE

Error
Every time I’ve run it, I get b’{“code”:124,“message”:“Invalid access token.”}’.

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

  1. Run code above with API key, secret and meeting number in appropriate places. (I used Visual Studio Code to run)
  2. See error 124

Additional context
I am newer to Python, and this could be a very simple mistake. Everything I’ve made here is based off of Zoom’s documentation and related staff recommendations on the forums, but I still can’t get it running. Any assistance would be appreciated.

Hi @ak201,

Thanks for reaching out! Do you run into the same error when testing this request directly in Postman or cURL?

Let me know,
Will

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