Spaces:
Sleeping
Sleeping
File size: 866 Bytes
bd1c43c a3e20c4 bd1c43c 4d3af55 bd1c43c a3e20c4 4d3af55 bd1c43c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import time
import urllib
from dotenv import load_dotenv
import requests
import json
import os
load_dotenv()
def get_meeting_token(room_name, daily_api_key, token_expiry):
api_path = os.getenv('DAILY_API_PATH') or 'https://api.daily.co/v1'
if not token_expiry:
token_expiry = time.time() + 600
res = requests.post(f'{api_path}/meeting-tokens',
headers={'Authorization': f'Bearer {daily_api_key}'},
json={'properties': {'room_name': room_name, 'is_owner': True, 'exp': token_expiry}})
if res.status_code != 200:
return json.dumps({'error': 'Unable to create meeting token', 'detail': res.text}), 500
#@TODO handle errors here
meeting_token = res.json()['token']
return meeting_token
def get_room_name(room_url):
return urllib.parse.urlparse(room_url).path[1:] |