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

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

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:

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

Hi @ryanaai ,

The Video SDK API endpoints require Video SDK JWT token to use. The instructions are here: Create a Video SDK app

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

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

Thank you!

1 Like

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