# agora-token

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

Latest version **2.0.6** (published 2026-08-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install agora-token
pnpm add agora-token
yarn add agora-token
bun add agora-token
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2026-08-31 |
| First published | 2022-09-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 201.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | agorabuilder |

## Links

- npm: https://www.npmjs.com/package/agora-token
- Homepage: https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/nodejs
- npm.io page: https://npm.io/package/agora-token

## Dependencies (3)

- [md5](https://npm.io/package/md5.md) ^2.3.0
- [cuint](https://npm.io/package/cuint.md) 0.2.2
- [crc-32](https://npm.io/package/crc-32.md) ^1.2.0

## Recent versions

- 2.0.6 (latest) — 2026-08-31
- 2.0.5 — 2025-05-29
- 2.0.4 — 2025-04-11
- 2.0.3 — 2023-05-31
- 2.0.2 — 2023-02-02
- 2.0.1 — 2023-02-02
- 2.0.0 — 2022-09-30

## README

# 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](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).

Before installing, [download and install Node.js](https://nodejs.org/en/download/).

Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):

```console
$ 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](https://github.com/AgoraIO/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]().

---
_Source: https://npm.io/package/agora-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
