prschmid/zoomus

"Invalid access token" issue

Closed this issue · 13 comments

Why would this bellow script, with the exact same key/secret, systematically fail on one server, and work just fine form another!!!
Both runs use same docker container, built from same Dockerfile... so same OS, libs, ….etc.

from zoomus import ZoomClient
import json
client = ZoomClient('###########','######################')

user_list_response = client.user.list()
user_list = json.loads(user_list_response.content)
print(user_list)
print("Done!")

Where it fails it prints:

[root@69981eb9a60f zoom]# /bin/python3 /workspaces/zoom/test-zoom.py
{'code': 124, 'message': 'Invalid access token.'}
Done!
[root@69981eb9a60f zoom]# 

Hi @lrhazi . Sorry to hear about your troubles!

What I've seen happen to folks in the past is that it's caused by an older version of PyJWT that was causing the issue. If you are sure that is not the culprit, have you tried to manually make requests to the Zoom API from that server?

Thanks @prschmid I am pretty sure am using same python version and same pip packages, but I will try to force rebuilds of the containers.

I tested with curl, using a token generated from my python script as follows:

print(f"Token: {client.config['token']}")

and it works:

[root@69981eb9a60f zoom]# curl --header "Content-Type: application/json" --header "Authorization: Bearer $TOK" --request POST --data '{"topic":"xyz","type":1}'  https://api.zoom.us/v2/users/me/meetings
{"uuid":"BV8GlLhtTUKGovrlp4Y1sg==","id":....

Not sure if this helps but FYI, this prints Invalid access token error, then the curl runs successfully printing list of users...

from zoomus import ZoomClient
import json
client = ZoomClient('<key>','<secret>')

user_list_response = client.user.list()
user_list = json.loads(user_list_response.content)
print(user_list)

token = client.config['token']

import subprocess
subprocess.call([
    "curl", 
    "--header",f"""Authorization: Bearer {token.decode("utf-8") }""",
    "https://api.zoom.us/v2/users"
    ])

What version of PyJWT and what version of zoomus are you using, @lrhazi ? I have also seen this error in the same situations that @prschmid described.

[root@69981eb9a60f zoom]# 
[root@69981eb9a60f zoom]# python3 -V
Python 3.6.8
[root@69981eb9a60f zoom]# pip3 list | grep -i jw
PyJWT (1.7.1)
[root@69981eb9a60f zoom]# 
[root@69981eb9a60f zoom]# pip3 list | grep -i zoom
zoomus (1.1.6)
[root@69981eb9a60f zoom]#

PyJWT seems to be your issue. If you take a look at the requirements file, you should be using PyJWT 2.0.1.

If you'd like more info on why it's important to bump to 2.0.1 you can take a look at #157

Thanks guys. will upgrade PyJWT.

Hello there, I'm having the same issue-
when I initialize the ZoomClient:

client = ZoomClient(KEY,SECRET)
type(client.config['token'])
>"bytes"

After refreshing the JWT token:

client.refresh_token()
type(client.config['token'])
>"tuple"

I'm also on PyJWT 2.0.1

Well that's new. That SOUNDS like you're on PyJWT 1.7 but you're sure you're on 2.0.1? Just for reference what version of zoomus?

ah sorry you are correct! I read the installed versions from the wrong virtual env. Updating that env has fixed the errors. Thanks!

Glad we were able to get everyone sorted! Closing this issue off for now. Happy coding.