xurshid29 / Agora-Node-TokenServer

A simple token server for Agora applications using NodeJS with Express, and Agora Access Token modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Agora Node Token Server

This is an example of a simple Node/Express server that generates tokens for Agora applications.

Deploy

Run the server

  • Install the dependencies
npm install
  • Create a copy of the .env.example file and save it as .env
  • Add your Agora App ID and App Certificate:
APP_ID=ca123xxxxxx
APP_CERTIFICATE=12za123xxxxxx

You can obtain these values by selecting your project in the Agora console projects section. Optionally, you can also define a port.

  • Start the service
npm start

Endpoints

Ping

endpoint structure

/ping

response:

{"message":"pong"} 

RTC Token

The rtc token endpoint requires a tokentype (uid || userAccount), channelName, and the user's uid (type varies based on tokentype). (optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rtc/:channelName/:role/:tokentype/:uid/?expiry=

response:

{"rtcToken":" "} 

RTM Token

The rtm token endpoint requires the user's uid. (optional) Pass an integer to represent the privelege lifetime in seconds. endpoint structure

/rtm/:uid/?expiry=

response:

{"rtmToken":" "} 

Both Tokens

The rte token endpoint generates both the rtc and rtm tokens with a single request. This endpoint requires a tokentype (uid || userAccount), channelName, and the user's uid (type varies String/Int based on tokentype). (optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rte/:channelName/:role/:tokentype/:uid/?expiry=

response:

{
  "rtcToken":" ",
  "rtmToken":" " 
} 

About

A simple token server for Agora applications using NodeJS with Express, and Agora Access Token modules.

License:MIT License


Languages

Language:JavaScript 99.4%Language:Shell 0.6%