Red5 Go SDK Documentation
The Red5 Go 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
go get github.com/red5pro/red5-bcs-go
Client Setup
Import the package and create a new client using your master credentials.
Example:
package main
import (
“fmt”
“log”
“github.com/red5pro/red5-bcs-go”
)
func main() {
masterKey := “YOUR_MASTER_KEY”
masterSecret := “YOUR_MASTER_SECRET”
}
Conference Tokens
Generate a token for joining a video conference room.
Function:
GetConferenceToken(userId, roomId, role string, expirationMinutes int) (string, error)
Parameters:
• userId – unique user ID
• roomId – conference room ID
• role – admin, publisher, or subscriber
• expirationMinutes – token validity duration (minutes)
Example:
conferenceToken, err := client.GetConferenceToken(
“someUser”,
“someRoom”,
“publisher”,
60,
)
fmt.Println(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 string, read, write bool, ttlMinutes int) (string, error)
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:
chatToken, err := client.GetChatToken(
“user123”,
“channel-global”,
true,
true,
30,
)
fmt.Println(chatToken)
Example: Full Application
package main
import (
“fmt”
“log”
“github.com/red5pro/red5-bcs-go”
)
func main() {
masterKey := “MASTER_KEY”
masterSecret := “MASTER_SECRET”
client, _ := red5bcs.NewRed5Client(masterKey, masterSecret)
// Admin conference token (2 hours)
adminToken, _ := client.GetConferenceToken(
"userA",
"room1",
"admin",
120,
)
fmt.Println(adminToken)
// Chat token (read/write)
chatToken, _ := client.GetChatToken(
"userA",
"channel1",
true,
true,
60,
)
fmt.Println(chatToken)
}