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

**URL:** <https://devforum.zoom.us/t/after-getting-token-in-python-response-is-still-400/76402>\
**Category:** Zoom Apps\
**Created:** [September 22, 2022, 3:14pm UTC](https://devforum.zoom.us/t/after-getting-token-in-python-response-is-still-400/76402 "2022-09-22T15:14:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![events9](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/events9/32/41652_2.png) [@events9](https://devforum.zoom.us/u/events9)\
**Post date:** [September 22, 2022, 3:14pm UTC](https://devforum.zoom.us/t/after-getting-token-in-python-response-is-still-400/76402/1 "2022-09-22T15:14:54Z")

</div>

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](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](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]\>----
