Generate time limited, i.e. ephemeral, long term credentials to authenticate against a TURN server. The default duration for the validity of the credentials is set to one day as recommended in A REST API For Access To TURN Services. The same document describes how to generate the username and password here.
- Python 3.8.10 on Ubuntu 20.04.2 LTS
(venv) $ pip install turn-ephemeral-credentials
(venv) $ pip install git+https://github.com/p4irin/turn_ephemeral_credentials.git
from turn_ephemeral_credentials import generate
# Generate a username and use the default ttl of one day
credentials = generate(shared_secret='A shared secret with a TURN server')
# Pass a username and use the default ttl
credentials = generate(username='username', shared_secret='A shared secret with a TURN server')
# Generate a username and use a ttl of half a day
credentials = generate(shared_secret='A shared secret with a TURN server', ttl=43200)
turn_username=credentials['turn_username']
turn_password=credentials['turn_password']