# Error Code 124 for Python JWT API

**URL:** <https://devforum.zoom.us/t/error-code-124-for-python-jwt-api/50232>\
**Category:** API and Webhooks\
**Created:** [May 13, 2021, 6:50pm UTC](https://devforum.zoom.us/t/error-code-124-for-python-jwt-api/50232 "2021-05-13T18:50:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ak201](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@ak201](https://devforum.zoom.us/u/ak201)\
**Post date:** [May 13, 2021, 6:50pm UTC](https://devforum.zoom.us/t/error-code-124-for-python-jwt-api/50232/1 "2021-05-13T18:50:07Z")

</div>

**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](http://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.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [May 14, 2021, 7:19pm UTC](https://devforum.zoom.us/t/error-code-124-for-python-jwt-api/50232/2 "2021-05-14T19:19:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [June 14, 2021, 5:19am UTC](https://devforum.zoom.us/t/error-code-124-for-python-jwt-api/50232/3 "2021-06-14T05:19:24Z")

</div>

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