Streaming Avatar SDK Best Practice
Learn how implement Streaming Avatar SDK step by step
Overview
When implementing a JavaScript SDK, especially one that interacts with sensitive resources or APIs, it is critical to ensure the security of private keys, tokens, and other sensitive credentials. Exposing such sensitive information in a client-side environment (e.g., browsers) can lead to vulnerabilities, including unauthorized access, token theft, and API abuse. This document outlines best practices for securing private keys and tokens in your Streaming Avatar SDK implementation while exposing only the necessary session data to the client.
- Never Expose Private Keys in the Client-Side Code
- Use Short-Lived Session as token
- Delegate Authentication to a Backend Server
- Handling avatar interactions and responses
- Managing audio streams and events
The integration uses Agora’s Real-Time Communication (RTC) SDK for reliable, low-latency streaming and our avatar service for generating responsive avatar behaviors.
Prerequisites
-
Get your Akool API Token from Akool Authentication API
-
Basic knowledge of backend services and internet security.
-
Basic knowledge of JavaScript and Http Request
Getting Started
1.To get started with the Streaming Avatar SDK, you just need one html page with lots of elements like below:
2.importing Streaming Avatar SDK:
3.Instantiation StreamingAvatar class and get session params form your backend:
- Sign up functions for steaming events and button click events: