Always get "Invalid access token." using python and jwt

The code is actually copied from zoom forum (Zoom JWT Token Creation - Automate the Process)

import jwt
import requests
import json
from time import time

API_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
# Specify the hashing alg
# Convert token to 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('', headers=headers)


When I run it, I always get
{“code”:124,“message”:“Invalid access token.”}

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

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

  1. create an, paste the code above, change key and sec,
  2. See error

I find the issue. I have to create a JWT app. Then use the key and secret generate for JWT app.
The previous one is a SDK app, that’s why it’s key and secret doesn’t work

Hey @TomJerry, glad you were able to figure this out! :100:


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