RESOLVED
To help someone else…
jwt.encode(…) returns a token in bytes, this must be decoded using token.decode() to use in your get request
Using this library (listed on jwt.io) https://pyjwt.readthedocs.io/en/latest/
I am getting {“code”:124,“message”:“Invalid access token.”}
This is my script:
import time
import datetime
import requests
import jwt
KEY =
SECRET =
header = {
“alg”: “HS256”,
“typ”: “JWT”
}
payload = {
“iss”: KEY,
“exp”: int(time.time() + 60)
}
token = jwt.encode(payload, SECRET, algorithm=‘HS256’, headers=header)
today = datetime.date.today()
yesterday = today - datetime.timedelta(1)
base_url = “https://api.zoom.us/v2/metrics/meetings”
r = requests.get(’%s/?type=%s&from=%s&to=%s’ % (base_url, “past”, yesterday, today),
headers={‘Authorization’: ‘Bearer %s’ % token})
print(r.content)