GithubHelp home page GithubHelp logo

agoraio-community / agora-node-tokenserver Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 79.0 39 KB

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

License: MIT License

JavaScript 99.37% Shell 0.63%

agora-node-tokenserver's Introduction

Agora Node Token Server

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

Deploy on Railway

Deploy to Render

Deploy on Heroku

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 channelName, role ('publisher' or 'audience'), tokentype ('uid' || 'userAccount') and the user's uid (type varies based on tokentype (example: 1000 for uid, ekaansh for userAccount). (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. (optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

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

response:

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.