mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Apparently, zoom's API will (sometimes?) return a 201 (not 200) created in response to the API request to create a call. We fix this by using the proper requests check for whether or not the request failed.
		
			
				
	
	
		
			27 lines
		
	
	
		
			717 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			717 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import requests
 | 
						|
import jwt
 | 
						|
from typing import Any, Dict, Optional
 | 
						|
import time
 | 
						|
 | 
						|
def request_zoom_video_call_url(user_id: str, api_key: str, api_secret: str) -> Optional[Dict[str, Any]]:
 | 
						|
    encodedToken = jwt.encode({
 | 
						|
        'iss': api_key,
 | 
						|
        'exp': int(round(time.time() * 1000)) + 5000
 | 
						|
    }, api_secret, algorithm='HS256').decode('utf-8')
 | 
						|
 | 
						|
    response = requests.post(
 | 
						|
        'https://api.zoom.us/v2/users/' + user_id + '/meetings',
 | 
						|
        headers = {
 | 
						|
            'Authorization': 'Bearer ' + encodedToken,
 | 
						|
            'content-type': 'application/json'
 | 
						|
        },
 | 
						|
        json = {}
 | 
						|
    )
 | 
						|
 | 
						|
    try:
 | 
						|
        response.raise_for_status()
 | 
						|
    except Exception:
 | 
						|
        return None
 | 
						|
 | 
						|
    return response.json()
 |