Hi, I am trying to create a meeting, for that I have created a general app. from which I am getting my client id and client secret. for now I am using it to only create sample api so I donot have any redirect URL.
import requests
import json
from datetime import datetime
import time
CLIENT_ID = ‘’
CLIENT_SECRET = '’
API_ACCOUNT_ID = '__’
def get_access_token():
“”“Get an access token for Zoom API authentication”“”
try:
url = “____”
data = {
“grant_type”: “client_credentials”
}
response = requests.post(url, auth=(CLIENT_ID, CLIENT_SECRET), data=data)
response.raise_for_status()
access_token = response.json()[“access_token”]
print(f"Obtained access token: {access_token}“)
return access_token
except requests.exceptions.RequestException as e:
print(f"Error getting access token: {e}”)
return None
def create_meeting(user_id, meeting_details):
“”“Create a Zoom meeting”“”
try:
url = f""
access_token = get_access_token()
if access_token:
headers = {
“Authorization”: f"Bearer {access_token}“,
“Content-Type”: “application/json”
}
meeting_details[“start_time”] = meeting_details[“start_time”].strftime(”%Y-%m-%dT%H:%M:%SZ")
response = requests.post(url, headers=headers, data=json.dumps(meeting_details))
response.raise_for_status()
print(f"Meeting created successfully: {response.json()[‘topic’]}“)
return response.json()
else:
return {“error”: “Failed to get access token”}
except requests.exceptions.RequestException as e:
print(f"Error creating meeting: {e}”)
print(f"Response status code: {e.response.status_code}“)
print(f"Response content: {e.response.content}”)
return {“error”: str(e)}
Example meeting details
meeting_details = {
“topic”: “My Meeting”,
“type”: 2,
“start_time”: datetime(2022, 3, 25, 7, 32, 55),
“duration”: 60,
“agenda”: “Discuss project updates”,
“settings”: {
“host_video”: True,
“participant_video”: False,
“join_before_host”: False,
“mute_upon_entry”: True,
“waiting_room”: False
}
}
result = create_meeting(API_ACCOUNT_ID, meeting_details)
if “error” in result:
print(f"Error: {result[‘error’]}")
this is sample code it is generating access token but
Error creating meeting: 401 Client Error: Unauthorized for url: ______
Response status code: 401
Response content: b’{“code”:124,“message”:“This API does not support client credentials for authorization.”}’
Error: 401 Client Error: Unauthorized for ur this is thrown. I think my api_acount_id might be wrong how do I get that.