# Zoom Meeting is Not Generating Using Python

**URL:** <https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763>\
**Category:** API and Webhooks\
**Created:** [September 10, 2023, 6:38am UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763 "2023-09-10T06:38:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shohagcsediu](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shohagcsediu/32/30991_2.png) [@shohagcsediu](https://devforum.zoom.us/u/shohagcsediu)\
**Post date:** [September 10, 2023, 6:38am UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/1 "2023-09-10T06:38:30Z")

</div>

In a python (backend) and javascript (frontend) based application I was using jwt app to generate zoom meeting. So as jwt is deprecated now I want to implement Server-to-Server OAuth/ OAuth app to create zoom meeting.

Please check the below code and let me know where is the issue that not working and which type app should be make .

```auto
import requests
import json
import base64

# The Zoom client ID and client secret
client_id = "CLIENT ID"
client_secret = "CLIENT SECRET"

# The URL of the Zoom OAuth token endpoint
url = "https://zoom.us/oauth/token"

# The request body
payload = {
    "grant_type": "client_credentials"
}

# The request headers
headers = {
    "Authorization": "Basic " + base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
}

# Make the request to the Zoom OAuth token endpoint
response = requests.post(url, headers=headers, data=payload)

# Check the response status code
if response.status_code == 200:
    # The request was successful, get the access token
    access_token = response.json()["access_token"]
    print("access token is", access_token)
else:
    # The request failed, raise an exception
    raise Exception("Failed to get access token")

# The topic of the meeting
topic = "My Meeting"

# The duration of the meeting in minutes
duration = 30

# The start time of the meeting in ISO 8601 format
start_time = "2023-09-10T13:00:00Z"

# The URL of the Zoom API endpoint to create a meeting
url = "https://api.zoom.us/v2/users/me/meetings"

# The request headers
headers = {
    "Authorization": f"Bearer {access_token}"
}

# The request body
payload = {
    "topic": topic,
    "duration": duration,
    "start_time": start_time
}

# Make the request to create the meeting
response = requests.post(url, headers=headers, data=payload)

# Check the response status code
if response.status_code == 200:
    # The request was successful, get the meeting ID
    meeting_id = response.json()["id"]
    print(f"Meeting created successfully, meeting ID: {meeting_id}")
else:
    # The request failed, raise an exception
    raise Exception("Failed to create meeting")

```

This code is working for creating token but at the end it’s not creating the meeting link . Error 400. If anyone have solved it please share. Advance thanks.

---

<div class="post-metadata">

**Author:** ![joshua.allen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/joshua.allen/32/51545_2.png) [@joshua.allen](https://devforum.zoom.us/u/joshua.allen)\
**Post date:** [September 10, 2023, 3:31pm UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/3 "2023-09-10T15:31:28Z")

</div>

Try using ‘json=payload’ instead of ‘data=payload’ in the request under the ‘# Make the request to create the meeting’

.

---

<div class="post-metadata">

**Author:** ![shohagcsediu](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shohagcsediu/32/30991_2.png) [@shohagcsediu](https://devforum.zoom.us/u/shohagcsediu)\
**Post date:** [September 11, 2023, 2:56am UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/4 "2023-09-11T02:56:47Z")

</div>

thanks for your reply, I tried this still not working ☹  
`response = requests.post(url, headers=headers, json=payload)`

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [September 11, 2023, 8:59am UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/5 "2023-09-11T08:59:45Z")

</div>

@shohagcsediu ,

the grant\_type and account\_type should be in the URL.

Here’s a partial sample to get the access\_token from S2S OAuth

```auto
import requests
import base64
import os
from dotenv import load_dotenv

# Load environment variables from .env file, this will try to load these values from your .env file
load_dotenv()

# Your .env file should look something like this

#CLIENT_ID='xxxxxxxxxx'
#CLIENT_SECRET='yyyyyyyyyyyyy'
#ACCOUNT_ID='zzzzzzzzzzzz'

# Access the environment variables
client_secret = os.getenv("CLIENT_SECRET")
client_id = os.getenv("CLIENT_ID")
account_id = os.getenv("ACCOUNT_ID")
oauth_url = 'https://zoom.us/oauth/token?grant_type=account_credentials&account_id='+account_id # Replace with your OAuth endpoint URL

def get_access_token():
    try:
        # Create the Basic Authentication header
        auth_header = f'Basic {base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()}'

        # Define the headers for the OAuth request
        headers = {
            'Authorization': auth_header,
        }

        # Make the OAuth request
        response = requests.post(oauth_url, headers=headers)

        # Check if the request was successful (status code 200)
        if response.status_code == 200:
            # Parse the JSON response to get the access token
            oauth_response = response.json()
            access_token = oauth_response.get('access_token')
            return access_token
        else:
            print(f'OAuth Request Failed with Status Code: {response.status_code}')
            print(response.text)
            return None
    except Exception as e:
        print(f'An error occurred: {str(e)}')
        return None

```

---

<div class="post-metadata">

**Author:** ![joshua.allen](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/joshua.allen/32/51545_2.png) [@joshua.allen](https://devforum.zoom.us/u/joshua.allen)\
**Post date:** [September 11, 2023, 4:03pm UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/6 "2023-09-11T16:03:33Z")

</div>

This may be a long shot but it may be order specific, Try putting in order of duration, start time, topic.

---

<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 14, 2024, 7:39am UTC](https://devforum.zoom.us/t/zoom-meeting-is-not-generating-using-python/94763/7 "2024-09-14T07:39:58Z")

</div>

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