File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ from functools import lru_cache
2+ import os
3+ from time import time
4+
5+ import jwt
6+ import requests
7+
8+ ZOOM_API = "https://api.zoom.us/v2/"
9+ SPEAKERS_CORNER_USER_ID = "D0n5UNEHQiajWtgdWLlNSA"
10+
11+ @lru_cache ()
12+ def zoom_headers (duration : int = 10 ) -> dict :
13+ zoom_api_key = os .getenv ("ZOOM_API_KEY" )
14+ zoom_api_secret = os .getenv ("ZOOM_API_SECRET" )
15+ token = jwt .encode (
16+ # Create a payload of the token containing API Key & expiration time
17+ {"iss" : zoom_api_key , "exp" : time () + duration },
18+ zoom_api_secret ,
19+ algorithm = 'HS256'
20+ ).decode ('utf-8' )
21+
22+ return {'authorization' : f'Bearer { token } ' , 'content-type' : 'application/json' }
23+
24+
25+ def speakers_corner_user_id () -> str :
26+ users = requests .get (ZOOM_API + "users" , headers = zoom_headers ()).json ()["users" ]
27+ sc_user_id = next (
28+ u ["id" ] for u in users
29+ if u ["first_name" ] == "Speakers'" and u ["last_name" ] == "Corner"
30+ )
31+ return sc_user_id
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import os
4+ import hashlib
5+ import datetime
6+
7+ import requests
8+ import pytz
9+
10+ import common
11+
12+ def host_key (salt : str , timeslot : datetime .datetime ) -> int :
13+ key_salt = os .getenv ("HOST_KEY_SALT" ).encode ()
14+ timestamp = timeslot .replace (second = 0 , microsecond = 0 , minute = 0 ).timestamp ()
15+ hashed = hashlib .sha512 (int (timestamp .to_bytes (5 , "big" )) + key_salt )
16+ return int (hashed .hexdigest (), 16 ) % int (1e7 )
17+
18+
19+ def update_host_key ():
20+ headers = common .zoom_headers ()
You can’t perform that action at this time.
0 commit comments