Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

agora-token

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agora-token

To enhance communication security, Agora uses tokens to authenticate users before they access the Agora service, or joining an RTC channel.

  • 2.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-21.62%
Maintainers
1
Weekly downloads
 
Created
Source

Authenticate Users with a token

To enhance communication security, Agora uses tokens to authenticate users before they access the Agora service, or joining an RTC channel.

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

Installation is done using the npm install command:

$ npm install agora-token

Code structure

Under the nodejs directory:

  • /src/ contains the source code for generating a token, where RtcTokenBuilder.js is used for generating an RTC token, and RtmTokenBuilder.js is used for generating an RTM token.
  • /sample/ contains the sample code for generating a token, where RtcTokenBuilderSample.js is used for generating an RTC token, and RtmTokenBuilderSample.js is used for generating an RTM token.

Generate a token with the sample code

This section takes RtcTokenBuilderSample.js as an example to show how to generate a token with the sample code.

Before proceeding, ensure that you have installed the LTS version of Node.js.

  1. Run the following command to install the Node.js dependencies:

    npm install
    
  2. Download or clone the Tools repository.

  3. Open the DynamicKey/AgoraDynamicKey/nodejs/sample/RtcTokenBuilderSample.js file, replace the value of appID, appCertificate, channelName, and uid with your own, and comment out the code snippets of buildTokenWithUserAccount.

  4. Open your Terminal, navigate to the same directory that holds RtcTokenBuilderSample.js, and run the following command. The token is generated and printed in your Terminal window.

    node RtcTokenBuilderSample.js
    

Reference

For a complete authentication flow between the app server and app client, see Authenticate Your Users with Tokens.

FAQs

Package last updated on 31 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc