Backend Authentication
SimliClient is awesome on it’s own. However, it uses the API key directly on client-side which isn’t so great for security as someone with a little bit of knowledge can get your API key. With SimliClient 1.2.7+, you can handle auth on your own backend by making the authentication request there and passing the session_token and ICE Config back to the client.
Getting Started
Usage
Step 0: Standard SimliClient
First, import the SimliClient
class into your project:
Make sure to replace 'YOUR_SIMLI_API_KEY'
with your actual Simli API key, and 'YOUR_FACE_ID'
with the desired face ID for your application.
Step 1: Creating our authentication backend:
This is a really simple backend with one goal, proxying /startAudioToVideoSession and /getIceServer to Simli servers and keeping the API key safe on your backend. This sample backend will now have any auth on it’s own as there’s no one good solution for that and you can pick whatever you like for your auth!
For this example, we’re using FastAPI with python but as we mentioned, you can use anything you like.
with the .env file being
and the requirements.txt file
Step 2: Modify Simli-Client usage
We can make a call to our backend (which we’re assuming is on 127.0.0.1:8000 for now), get the session token and IceServers config and give them to the Simli-Client instance