INNER CODE UNIT · Python

turn_rest

selkies-project/selkies · addons/turn-rest/app.py:111

def turn_rest():
    """Mint a time-limited TURN credential per the TURN REST API.

    Returns:
        JSON with ``username`` (`expiry:user`), the HMAC-SHA1 ``password``,
        ``ttl``, and the ``uris`` list, or a plain-text error with a 4xx
        status for a bad service or API key.
    """
    json_payload = request.get_json(silent=True)

    service_input = str(get_param('service', json_payload) or 'turn').strip().lower()
    if service_input not in ('', 'turn'):
        return "Invalid service sent. Only 'turn' is supported.\n", 400

    if turn_api_key:
        api_key_input = get_param('key', json_payload) or get_param('api', json_payload)
        if not api_key_input:
            return "Invalid service and/or key sent.\n", 400

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…