# How to fetch a list of recordings in a Python script with OAuth

**URL:** <https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575>\
**Category:** API and Webhooks\
**Tags:** api\
**Created:** [September 6, 2023, 8:09pm UTC](https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575 "2023-09-06T20:09:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanaai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ryanaai/32/51783_2.png) [@ryanaai](https://devforum.zoom.us/u/ryanaai)\
**Post date:** [September 6, 2023, 8:09pm UTC](https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575/1 "2023-09-06T20:09:13Z")

</div>

# Description

Hi there,

I am working with a script that currently **uses JWT to fetch Zoom recordings** that are stored on the cloud. Since **JWT support is being sunsetted** , I am looking to replace this workflow with a server-to-server OAuth workflow.

From my understanding of OAuth, it is generally inteded for end-user web applications to give restricted authorization for external services/servers to access user data.

I am wondering what the canonical approach is to using OAuth in my case, in which I simply would like to **run a script that fetches a list of my recordings** so that I may programmatically download one or some of them?

I will post my attempts and results below if relevant.

Thanks in advance for any advice!

# Attempt 1

```python
import requests
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

client_id = 'MY_CLIENT_ID'
client_secret = 'MY_CLIENT_SECRET'

client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)

# https://developers.zoom.us/docs/internal-apps/s2s-oauth/
URL = "https://zoom.us/oauth/token"
token = oauth.fetch_token(token_url=URL, client_id=client_id,
        client_secret=client_secret)

resp = requests.get("https://api.zoom.us/v2/videosdk/recordings",
                    headers={
                        'Authorization': f"Bearer {token['access_token']}"
                    })

resp.json()

```

The result is a 200 status code with a message that says **`Account does not enabled REST API.`**. I tried this with both an account-level and user-managed app. I am using a paid company account, and I have checked with our Zoom admin that `View` and `Edit` for `Server-to-Server Oauth app` are both enabled.

# Attempt 2

I also tried the below:

```python
import requests
import json

client_id = "MY_CLIENT_ID"
client_secret = "MY_CLIENT_SECRET"

meeting_id = "MEETING_ID"

data = {
    "grant_type": "account_credentials",
    "client_id": client_id,
    "client_secret": client_secret
}
response = requests.post("https://zoom.us/oauth/token", data=data)
print(response.json())
access_token = response.json()["access_token"]

headers = {
    "Authorization": f"Bearer {access_token}"
}

url = f"https://api.zoom.us/v2/metrics/meetings/{meeting_id}/report"

response = requests.get(url, headers=headers)

print(json.dumps(response.json(), indent=4))

```

I get a `KeyError` for `response.json()['access-token']`, and when I print `response,json()` I see `{'reason': 'unsupported grant type', 'error': 'unsupported_grant_type'}`

If anyone has advice that would be great! Thanks

---

<div class="post-metadata">

**Author:** ![gianni.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/gianni.zoom/32/32523_2.png) [@gianni.zoom](https://devforum.zoom.us/u/gianni.zoom)\
**Post date:** [September 6, 2023, 9:55pm UTC](https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575/2 "2023-09-06T21:55:57Z")

</div>

Hi @ryanaai ,

> [@ryanaai](#):
>
> Attempt 1

The Video SDK API endpoints require Video SDK JWT token to use. The instructions are here: [https://developers.zoom.us/docs/video-sdk/create/#video-sdk-api](https://developers.zoom.us/docs/video-sdk/create/#video-sdk-api)

> [@ryanaai](#):
>
> Attempt 2

It is okay to use S2S OAuth with Meeting API, but you need to pass account\_id to the OAuth token endpoint to retrieve a valid token: `https://zoom.us/oauth/token?grant_type=account_credentials&account_id=[account_id]`

Please confirm you have a valid token and then call the Dashboard endpoint again.  
[https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-875f65b4-d88f-4082-80af-7605303a5abc](https://www.postman.com/zoom-developer/workspace/zoom-public-workspace/request/22097587-875f65b4-d88f-4082-80af-7605303a5abc)

---

<div class="post-metadata">

**Author:** ![ryanaai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ryanaai/32/51783_2.png) [@ryanaai](https://devforum.zoom.us/u/ryanaai)\
**Post date:** [September 7, 2023, 5:36pm UTC](https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575/4 "2023-09-07T17:36:14Z")

</div>

Hi @gianni.zoom! I got everything working with your advice and some additional reading 👍

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 8, 2023, 5:36pm UTC](https://devforum.zoom.us/t/how-to-fetch-a-list-of-recordings-in-a-python-script-with-oauth/94575/5 "2023-09-08T17:36:32Z")

</div>

Closed on September 8, 2023, 5:36pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
