Agora Tools Documentation

repository·master·Indexed 19 days ago

https://github.com/agoraio/tools

A collection of utilities to enhance the Agora SDK experience, featuring token generation, user simulation, proxying, and diagnostic tools. It includes the AgoraDynamicKey library for generating RTC and RTM tokens across multiple languages including C++, Dart (Flutter), Deno/Node.js, and Go. The toolkit provides high-level wrappers like RtcTokenBuilder and RtmTokenBuilder, as well as a deployable Token Service via Docker for production environments.

Tokens
42.6K
Snippets
144
Records
193
Agent score
56%

What's inside Agora Tools

  1. PHP Token Builder directory structure

    master

    The PHP implementation of the Agora Dynamic Key tool is organized into two main directories:

    • src/: Contains the core logic for token generation.
      • RtcTokenBuilder.php: Used for generating RTC (Real-Time Communication) tokens.
      • RtmTokenBuilder.php: Used for generating RTM (Real-Time Messaging) tokens.
    • sample/: Contains ready-to-run example scripts.
      • RtcTokenBuilderSample.php: A sample script for generating RTC tokens.
      • RtmTokenBuilderSample.php: A sample script for generating RTM tokens.
  2. Python DynamicKey directory structure

    master

    The DynamicKey/AgoraDynamicKey/python/ directory is organized into two main parts:

    • /src/: Contains the core logic for token generation.
      • RtcTokenBuilder.py: Used for generating RTC tokens.
      • RtmTokenBuilder.py: Used for generating RTM tokens.
    • /sample/: Contains ready-to-run sample implementations.
      • RtcTokenBuilderSample.py: Sample for generating RTC tokens.
      • RtmTokenBuilderSample.py: Sample for generating RTM tokens.
  3. Structure of the AgoraDynamicKey Node.js directory

    master

    The DynamicKey/AgoraDynamicKey/nodejs/ directory is organized into two main parts:

    • /src/: Contains the core logic for token generation.
      • RtcTokenBuilder.js: Used for generating RTC tokens.
      • RtmTokenBuilder.js: Used for generating RTM tokens.
    • /sample/: Contains implementation examples.
      • RtcTokenBuilderSample.js: A sample script for generating RTC tokens.
      • RtmTokenBuilderSample.js: A sample script for generating RTM tokens.
  4. Rust Agora Dynamic Key directory structure

    master

    The rust directory within DynamicKey/AgoraDynamicKey/ is organized as follows:

    • /src/: Contains the core logic for token generation.
      • rtc_token_builder: Used for generating RTC tokens.
      • rtm_token_builder: Used for generating RTM tokens.
    • /examples/: Contains runnable sample code demonstrating how to use the builders.
      • rtc_token_builder.rs: Example for generating RTC tokens.
      • rtm_token_builder.rs: Example for generating RTM tokens.
  5. Lua Token Builder Directory Structure

    master

    The Lua implementation for token generation is organized as follows:

    • src/: Contains the core logic for token generation.
      • rtc_token_builder: Used for generating RTC (Real-Time Communication) tokens.
      • rtm_token_builder: Used for generating RTM (Real-Time Messaging) tokens.
    • sample/: Contains example implementations, including multi-service AccessToken2 token generation.
  6. Structure of the AgoraDynamicKey Python package

    master

    The python3 directory within DynamicKey/AgoraDynamicKey/ is organized into two main components:

    • /src/: Contains the core logic for token generation.
      • RtcTokenBuilder.py: Used for generating RTC (Real-Time Communication) tokens.
      • RtmTokenBuilder.py: Used for generating RTM (Real-Time Messaging) tokens.
    • /sample/: Contains implementation examples for testing and integration.
      • RtcTokenBuilderSample.py: A sample script for generating RTC tokens.
      • RtmTokenBuilderSample.py: A sample script for generating RTM tokens.
  7. Understand the Agora DynamicKey Java project structure

    master

    The DynamicKey/AgoraDynamicKey/java directory is organized into source code for token generation and sample implementations:

    • RTC Token Generation: Located in /src/main/java/io/agora/media/. Use RtcTokenBuilder.java to generate RTC tokens.
    • RTM Token Generation: Located in /src/main/java/io/agora/rtm/. Use RtmTokenBuilder.java to generate RTM tokens.
    • Sample Code: Located in /src/main/java/io/agora/sample/.
      • RtcTokenBuilderSample.java demonstrates RTC token generation.
      • RtmTokenBuilderSample.java demonstrates RTM token generation.
  8. C++ AgoraDynamicKey directory structure

    master

    The cpp directory in DynamicKey/AgoraDynamicKey/ is organized into source code and sample implementations:

    • /src/: Contains the core logic for token generation.
      • RtcTokenBuilder.h: Header for generating RTC tokens.
      • RtmTokenBuilder.h: Header for generating RTM tokens.
    • /sample/: Contains ready-to-use sample code for testing.
      • RtcTokenBuilderSample.cpp: Sample for generating RTC tokens.
      • RtmTokenBuilderSample.cpp: Sample for generating RTM tokens.
  9. What is AgoraDynamicKey and how to choose between AccessToken and Dynamic Key

    master

    AgoraDynamicKey provides the authentication mechanism for the Agora SDK. It supports two main types of tokens:

    1. AccessToken (v2.1.0+): The recommended approach. It is more powerful than the legacy Dynamic Key because it encapsulates multiple privileges into a single token to cover various Agora services. Agora recommends using AccessToken2 (version 007).
    2. Dynamic Key (v2.0.2 or earlier): The legacy authentication method.

    For a quick deployable sample server to test your implementation, you can use the TokenServer-nodejs repository.

  10. Determine which token type to use (RTC vs RTM)

    master

    Choosing the correct token depends on the Agora SDK you are using:

    RTC Tokens

    Use an RTC token for the following SDKs:

    • Agora Native SDK v2.1+
    • Agora Web SDK v2.4+
    • Agora Recording SDK v2.1+
    • Agora RTSA SDK

    Note for RTSA SDK: If you are using the Agora RTSA SDK and joining multiple channels simultaneously, you MUST generate a specific, unique token for each individual channel you join.

    RTM Tokens

    Use an RTM token for the:

    • Agora RTM SDK
  11. Generate access tokens with AgoraDynamicKey

    master
    The DynamicKey/AgoraDynamicKey component provides the implementation details for the Agora SDK authentication mechanism. It includes the necessary source code required to generate access tokens for authenticating users within the SDK.
  12. Understand the relationship between Token Builders and AccessToken.py

    master

    The token generation logic in this package is structured in two layers:

    1. Core Logic (AccessToken.py): Implements all underlying cryptographic algorithms required for token generation.
    2. Wrappers (RtcTokenBuilder.py and RtmTokenBuilder.py): These provide much easier-to-use APIs tailored to specific SDK types.

    Recommendation: Do not use AccessToken.py directly unless you have specific requirements. Instead, use RtcTokenBuilder.py for generating RTC tokens and RtmTokenBuilder.py for generating RTM tokens.