Red5 Documentation

Red5 Node SDK Documentation

The Red5 Node Backend SDK allows your backend server to generate secure tokens for:

• Video conferences

• Real-time chat messaging

Use these tokens in your Red5 frontend applications to authenticate users without exposing your master credentials.


Installation

npm install red5-bcs-node


Client Setup

Import the package and create a new client using your master credentials.

Example:

import Red5Client from ‘red5-bcs-node’;

const masterKey = ‘YOUR_MASTER_KEY’;
const masterSecret = ‘YOUR_MASTER_SECRET’;

const client = new Red5Client(masterKey, masterSecret);

Conference Tokens

Generate a token for joining a video conference room.

Function:

getConferenceToken(userId, roomId, role, expirationMinutes)

Parameters:

• userId – unique user ID

• roomId – conference room ID

• role – admin, publisher, or subscriber

• expirationMinutes – token validity duration (minutes)

Example:

const conferenceToken = await client.getConferenceToken(
“someUser”,
“someRoom”,
“publisher”,
60
);

console.log(conferenceToken);

Roles

admin

• Full access and conference management

publisher

• Can publish audio/video streams

subscriber

• View-only permissions


Chat Tokens

Generate a token for secure chat messaging.

Function:

getChatToken(userId, channelId, read, write, ttlMinutes)

Parameters:

• userId – unique user identity

• channelId – chat room ID

• read – grant message read permission

• write – grant message send permission

• ttlMinutes – token validity duration (minutes)

Example:

const chatToken = await client.getChatToken(
“user123”,
“channel-global”,
true,
true,
30
);

console.log(chatToken);

Example: Full Application

import Red5Client from ‘red5-bcs-node’;

async function main() {
const masterKey = “MASTER_KEY”;
const masterSecret = “MASTER_SECRET”;

const client = new Red5Client(masterKey, masterSecret);

// Admin conference token (2 hours)
const adminToken = await client.getConferenceToken(
“userA”,
“room1”,
“admin”,
120
);
console.log(adminToken);

// Chat token (read/write)
const chatToken = await client.getChatToken(
“userA”,
“channel1”,
true,
true,
60
);
console.log(chatToken);
}

main();