Live JavaScript v1
Live JavaScript
Live
JavaScript
Home
/
Live
/
JavaScript

Authentication

You can start building a live streaming experience with chat by installing Sendbird Live SDK. Installing the Live SDK will also install Sendbird Chat SDK which provides chat features in the Live SDK.

Before using the features of Sendbird Live SDK for JavaScript, your application must initialize the SDK, authenticate a user, and be connected with the Sendbird server. Then, the instance can communicate and interact with the server using an authenticated user account, allowing them to use the features of the Live SDK.


Authenticate to the Sendbird server

In order to use the Live SDK in the client app, initialize the SDK with your Sendbird application ID when you first launch the client app. You can find your application ID on Sendbird Dashboard.

import { SendbirdLive } from '@sendbird/live'

SendbirdLive.init({
    appId: APP_ID
});

Once you’ve initialized the client app, authenticate a user by calling SendbirdLive.authenticate(). Calling this method also authenticates the user with Sendbird Chat SDK which provides the chat functionality during a live event.

try {
    await SendbirdLive.authenticate(USER_ID, ACCESS_TOKEN);
} catch (e) {
    // Handle error.
}

Deauthenticate from the Sendbird server

When the user no longer needs to use the features of Sendbird Live SDK, it is recommended to disconnect the user from the server. Calling the SendbirdLive.deauthenticate() method also disconnects the user from Sendbird Chat SDK as well.

try {
    await SendbirdLive.deauthenticate(); 
    // A user is successfully deauthenticated.
} catch (e) {
    // Handle error.
}