After getting Token in Python, response is still [400]

I am using server-to-server oauth2 authentication in Jupyter Notebooks with Python 3 kernel. Although I can get a token, I get a bad response. I checked and our account has permissions, and I have created a Zoom App creating the keys.

+In[1]:+
[source, ipython3]

import requests
from requests_oauthlib import OAuth2, OAuth2Session
from oauthlib.oauth2 import BackendApplicationClient

USER = ‘private’
PWD = ‘private’


+In[2]:+
[source, ipython3]

integration_key = ‘private’
integration_secret = ‘private’

account_id = ‘private’
client_id = ’ private’
client_secret = ‘private’
secret_token = ‘private’


+In[3]:+
[source, ipython3]

client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)
token = oauth.fetch_token(
token_url=‘https://zoom.us/oauth/token’,
client_id=client_id,
client_secret=client_secret
)
token


+Out[3]:+
----{‘access_token’: ‘private’,
‘token_type’: ‘bearer’,
‘expires_in’: 3599,
‘scope’: [‘meeting:read:admin’,
‘report:read:admin’,
‘user:read:admin’,
‘webinar:read:admin’],
‘expires_at’: 1663862143.2224693}----

+In[4]:+
[source, ipython3]

myToken = token[‘access_token’]
myUrl = ‘https://api.zoom.us/v2/users/me/webinars
params = {
“grant_type”: “account_credentials”,
“account_id”: account_id
}
head = {
“Content-Type”: “application/json”,
“Authorization”: “Bearer {}”.format(myToken)
}
‘’’
?grant_type=account_credentials&account_id={account_id}

response = oauth.get(myUrl, params=params, headers=head)
response.json()
‘’’
session = OAuth2Session(token={‘access_token’: myToken})
#session.post(myUrl)

response = session.get(myUrl, params=params, headers=head)
response.json()


+Out[4]:+
----{‘code’: 200, ‘message’: ‘Invalid api key or secret.’}----

+In[5]:+
[source, ipython3]

response


+Out[5]:+
----<Response [400]>----