Description
I cannot seem to create a valid access token to get a zak. I have created a General App and enabled the Meeting SDK with scope that includes “user:read:zak”
Error?
401 - {“code”:124,“message”:“Invalid access token.”}
Troubleshooting Routes
I have gone through a lot of the posts and tried various payloads including all the required pieces from the Meeting SDK Auth page. I also tried using a token generated from the Meeting SDK Auth page which also comes back as invalid.
I also tried including “sdkKey” as part of the payload as it was in the example JWT provided on the same page. I’ve tried change the iat and exp times to account for possible time zone differences (i.e. also on the referenced page -30 and 2 hour window). Any suggestions? Thanks.
Here’s the python code with keys removed.
import jwt
import time
import requests
from datetime import datetime, timedelta
def generate_zoom_jwt(sdk_key, sdk_secret):
header = {
"alg": "HS256",
"typ": "JWT"
}
iat = int(time.time()) - 30
exp = iat + 60 * 60 * 2
payload = {
"appKey": sdk_key,
"mn": "****",
"role": 0,
"iat": iat,
"exp": exp,
"tokenExp": exp
}
token = jwt.encode(payload, sdk_secret, algorithm="HS256")
return token
CLIENT_ID = "***"
CLIENT_SECRET = "***"
try:
zoom_token = generate_zoom_jwt(CLIENT_ID, CLIENT_SECRET)
print("Generated JWT:")
print(zoom_token)
headers = {
"Authorization": f"Bearer {zoom_token}",
"Content-Type": "application/json"
}
print(headers)
response = requests.get("https://api.zoom.us/v2/users/me/zak", headers=headers)
if response.status_code == 200:
zak_data = response.json()
zak_token = zak_data.get("token")
print(f"ZAK Token: {zak_token}")
else:
print(f"Error generating ZAK token: {response.status_code} - {response.text}")
except Exception as e:
print(f"An error occurred: {e}")