Description
The code is actually copied from zoom forum (Zoom JWT Token Creation - Automate the Process)
import jwt
import requests
import json
from time import timeAPI_KEY = ‘???’
API_SEC = ‘???’
#create a function to generate a token using the pyjwt library
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 alg
algorithm=‘HS256’
# Convert token to utf-8
).decode(‘utf-8’)return token
#send a request with headers including a token
def getUsers():
headers = {‘authorization’: ‘Bearer %s’ % generateToken(),
‘content-type’: ‘application/json’}r = requests.get('https://api.zoom.us/v2/users/', headers=headers) print(r.text)
Error
When I run it, I always get
{“code”:124,“message”:“Invalid access token.”}
Which App Type (OAuth / Chatbot / JWT / Webhook)?
JWT
How To Reproduce (If applicable)
Steps to reproduce the behavior:
- create an test.py, paste the code above, change key and sec,
python3 test.py - See error