Security within video chat applications is a hot topic at the moment. As remote working and virtual events become more prolific, the need for security will increase.

Within the Agora Platform, one layer of security comes in the form of token authentication. A token, for those of you that don’t know, is a dynamic key that is generated using a set of given inputs. Agora’s Platform uses tokens to authenticate users.

Agora offers token security for both its RTC and RTM SDKs. This guide will explain how to build a simple microservice using NodeJS and Express to generate an Agora RTC token. The example can easily be adapted to include an RTM token as it follows a similar pattern.

Prerequisites

  • A basic understanding of JavaScript ES6, NodeJS, and NPM
  • (minimal knowledge needed)
  • An understanding of how express web servers function
  • (minimal knowledge needed)
  • An Agora Developer Account (see: How To Get Started with Agora)

Project Setup

To start our project we’ll create a new folder and open a terminal window at this folder.

Image for post

I named my folder AgoraTokenServer

In the terminal, we’ll run npm init to set up the node project. The create project prompt will appear. I used the default settings, but feel free to customize this portion.

Now that the project has been created, we can add our NPM dependencies (express and agora-access-token) using:

npm install express
npm install agora-access-token

Image for post

#nodejs #expressjs #node-js-tutorial #javascript

How to Build a Token Server for Agora Applications using NodeJS
16.50 GEEK