### Install Dependencies and Start Server Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/nodejs/server/README.md Installs the necessary Node.js packages and launches the demo server. Ensure you are in the project root directory before running these commands. ```shell npm i node DemoServer.js ``` -------------------------------- ### Project Build and Run Commands Source: https://github.com/agoraio/tools/blob/master/TroubleShooting/Agora-WebRTC-Troubleshooting/README.md Standard CLI commands for installing dependencies and running the development server for the Agora sample application. ```bash npm install npm run dev npm run build ``` -------------------------------- ### Deploy Token Service using Docker Commands Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Instructions to start the Agora Token Service using a single Docker command. ```APIDOC ## Deploying the Token Service Using Docker ### Option 1: Start the Service Using Docker Commands Use the following Docker command to start the Token service: ``` docker run -d -it -p 8080:8080 -e APP_ID=[YOUR_APP_ID] -e APP_CERTIFICATE=[YOUR_APP_CERTIFICATE] --name agora-token-service agoracn/token:0.1.2023053011 ``` > Replace `[YOUR_APP_ID]` and `[YOUR_APP_CERTIFICATE]` with your App ID and App Certificate. After the service starts, you can use the following `curl` command to test it: ``` curl --location 'http://localhost:8080/token/generate' \ --header 'Content-Type: application/json' \ --data '{ "channelName": "channel_name_test", "uid": "12345678", "tokenExpireTs": 3600, "privilegeExpireTs": 3600, "serviceRtc": { "enable": true, "role": 1 }, "serviceRtm": { "enable": true } }' ``` > You can deploy the service on a virtual machine or [Alibaba Cloud ECS](https://www.aliyun.com/product/ecs), and after deployment, you need to replace `localhost` with your server's IP address. For more information about the parameters, refer to [docker/server.go](docker/server.go). ``` -------------------------------- ### Deploy Token Service using Docker Compose Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Instructions to start the Agora Token Service using Docker Compose. ```APIDOC ### Option 2: Start the Service Using Docker Compose In the `docker` directory, open the `docker-compose.yaml` file and set the `APP_ID` and `APP_CERTIFICATE` parameters. Then, use the following command to start the service: ``` docker-compose up ``` > You can modify the source code as needed. The source code can be found in [docker/server.go](docker/server.go). ``` -------------------------------- ### Start Token Service with Docker Compose Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Command to launch the token service using a pre-configured docker-compose.yaml file. Ensure environment variables are set in the YAML file before execution. ```bash docker-compose up ``` -------------------------------- ### Deploy Token Service with Docker Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Command to start the Agora token service container. Replace the placeholder environment variables with your actual Agora credentials. ```bash docker run -d -it -p 8080:8080 -e APP_ID=[YOUR_APP_ID] -e APP_CERTIFICATE=[YOUR_APP_CERTIFICATE] --name agora-token-service agoracn/token:0.1.2023053011 ``` -------------------------------- ### Generate RTC Token with Lua Example Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/lua/README.md This snippet demonstrates how to generate an RTC token using the `rtc_token_builder.lua` script. Ensure Lua is installed and the Agora Tools repository is cloned. Replace placeholder values for App ID, App Certificate, Channel Name, and UID before running the script. ```lua local app_id = "YOUR_APP_ID" local app_certificate = "YOUR_APP_CERTIFICATE" local channel_name = "YOUR_CHANNEL_NAME" local uid = "YOUR_USER_ID" local rtc_token = require("agora_token_builder").build_token_with_uid(app_id, app_certificate, channel_name, uid, 3600) -- 1 hour expiry print("RTC Token: " .. rtc_token) ``` -------------------------------- ### Build Agora RTC Token with UID and Account (Node.js & PHP) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md These examples demonstrate how to build Agora RTC tokens using the RtcTokenBuilder. They show token generation for both integer UIDs and string user accounts, with options for specifying token and privilege expiration times. Ensure AGORA_APP_ID and AGORA_APP_CERTIFICATE environment variables are set. ```javascript const RtcTokenBuilder = require("../src/RtcTokenBuilder2").RtcTokenBuilder; const RtcRole = require("../src/RtcTokenBuilder2").Role; // Need to set environment variable AGORA_APP_ID const appId = process.env.AGORA_APP_ID; // Need to set environment variable AGORA_APP_CERTIFICATE const appCertificate = process.env.AGORA_APP_CERTIFICATE; const channelName = "7d72365eb983485397e3e3f9d460bdda"; const uid = 2882341273; const account = "2882341273"; const role = RtcRole.PUBLISHER; const tokenExpirationInSecond = 3600; const privilegeExpirationInSecond = 3600; const joinChannelPrivilegeExpireInSeconds = 3600; const pubAudioPrivilegeExpireInSeconds = 3600; const pubVideoPrivilegeExpireInSeconds = 3600; const pubDataStreamPrivilegeExpireInSeconds = 3600; console.log("App Id:", appId); console.log("App Certificate:", appCertificate); if (appId == undefined || appId == "" || appCertificate == undefined || appCertificate == "") { console.log("Need to set environment variable AGORA_APP_ID and AGORA_APP_CERTIFICATE"); process.exit(1); } // Build token with uid const tokenWithUid = RtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, role, tokenExpirationInSecond, privilegeExpirationInSecond); console.log("Token with int uid:", tokenWithUid); // Build token with user account const tokenWithUserAccount = RtcTokenBuilder.buildTokenWithUserAccount( appId, appCertificate, channelName, account, role, tokenExpirationInSecond, privilegeExpirationInSecond ); console.log("Token with user account:", tokenWithUserAccount); const tokenWithUidAndPrivilege = RtcTokenBuilder.buildTokenWithUidAndPrivilege( appId, appCertificate, channelName, uid, tokenExpirationInSecond, joinChannelPrivilegeExpireInSeconds, pubAudioPrivilegeExpireInSeconds, pubVideoPrivilegeExpireInSeconds, pubDataStreamPrivilegeExpireInSeconds ); console.log("Token with int uid and privilege:", tokenWithUidAndPrivilege); const tokenWithUserAccountAndPrivilege = RtcTokenBuilder.BuildTokenWithUserAccountAndPrivilege( appId, appCertificate, channelName, account, tokenExpirationInSecond, joinChannelPrivilegeExpireInSeconds, pubAudioPrivilegeExpireInSeconds, pubVideoPrivilegeExpireInSeconds, pubDataStreamPrivilegeExpireInSeconds ); console.log("Token with user account and privilege:", tokenWithUserAccountAndPrivilege); ``` ```php #include #include "../src/RtcTokenBuilder2.h" using namespace agora::tools; int main(int argc, char const *argv[]) { (void)argc; (void)argv; // Need to set environment variable AGORA_APP_ID const char *env_app_id = getenv("AGORA_APP_ID"); std::string app_id = env_app_id ? env_app_id : ""; // Need to set environment variable AGORA_APP_CERTIFICATE const char *env_app_certificate = getenv("AGORA_APP_CERTIFICATE"); std::string app_certificate = env_app_certificate ? env_app_certificate : ""; std::string channel_name = "7d72365eb983485397e3e3f9d460bdda"; uint32_t uid = 2882341273; std::string account = "2882341273"; uint32_t token_expiration_in_seconds = 3600; uint32_t privilege_expiration_in_seconds = 3600; uint32_t join_channel_privilege_expiration_in_seconds = 3600; uint32_t pub_audio_privilege_expiration_in_seconds = 3600; uint32_t pub_video_privilege_expiration_in_seconds = 3600; uint32_t pub_data_stream_privilege_expiration_in_seconds = 3600; std::string result; std::cout << "App Id:" << app_id << std::endl; std::cout << "App Certificate:" << app_certificate << std::endl; if (app_id == "" || app_certificate == "") { std::cout << "Need to set environment variable AGORA_APP_ID and " "AGORA_APP_CERTIFICATE" << std::endl; return -1; } result = RtcTokenBuilder2::BuildTokenWithUid( app_id, app_certificate, channel_name, uid, UserRole::kRolePublisher, token_expiration_in_seconds, privilege_expiration_in_seconds); std::cout << "Token With Int Uid:" << result << std::endl; result = RtcTokenBuilder2::BuildTokenWithUserAccount( app_id, app_certificate, channel_name, account, UserRole::kRolePublisher, token_expiration_in_seconds, privilege_expiration_in_seconds); std::cout << "Token With UserAccount:" << result << std::endl; result = RtcTokenBuilder2::BuildTokenWithUid( app_id, app_certificate, channel_name, uid, token_expiration_in_seconds, join_channel_privilege_expiration_in_seconds, pub_audio_privilege_expiration_in_seconds, pub_video_privilege_expiration_in_seconds, pub_data_stream_privilege_expiration_in_seconds); std::cout << "Token With Int Uid:" << result << std::endl; result = RtcTokenBuilder2::BuildTokenWithUserAccount( app_id, app_certificate, channel_name, account, token_expiration_in_seconds, join_channel_privilege_expiration_in_seconds, pub_audio_privilege_expiration_in_seconds, pub_video_privilege_expiration_in_seconds, pub_data_stream_privilege_expiration_in_seconds); std::cout << "Token With UserAccount:" << result << std::endl; return 0; } ``` -------------------------------- ### Configure Shadowsocks Proxy for RTC SDK Source: https://context7.com/agoraio/tools/llms.txt Configures a Shadowsocks proxy to route RTC SDK traffic through a secure tunnel. This setup involves a JSON configuration file and commands to start both the server and local client. ```json { "server": "your_server_ip", "server_port": 8388, "local_address": "127.0.0.1", "local_port": 1080, "password": "your_password", "timeout": 300, "method": "aes-256-cfb" } ``` ```bash ssserver -c shadowsocks.json sslocal -c shadowsocks.json ``` -------------------------------- ### PHP RTC Token Generation Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Examples of generating RTC tokens in PHP using the RtcTokenBuilder2. ```APIDOC ## PHP RTC Token Generation ### Description This section demonstrates how to generate Agora RTC tokens using PHP. It covers building tokens with both integer user IDs (uid) and string user accounts, and includes options for setting specific privilege expiration times. ### Method N/A (Client-side SDK usage) ### Endpoint N/A (Client-side SDK usage) ### Parameters - `$appId` (string) - Required - Your Agora Application ID. - `$appCertificate` (string) - Required - Your Agora Application Certificate. - `$channelName` (string) - Required - The name of the channel. - `$uid` (integer) - Required - The user ID for the token. - `$uidStr` (string) - Required - The user account for the token. - `ROLE_PUBLISHER` (constant) - Required - Role constant for publisher. - `$tokenExpirationInSeconds` (integer) - Required - The expiration time for the token in seconds. - `$privilegeExpirationInSeconds` (integer) - Optional - The expiration time for general privileges in seconds. - `$joinChannelPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the join channel privilege in seconds. - `$pubAudioPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish audio privilege in seconds. - `$pubVideoPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish video privilege in seconds. - `$pubDataStreamPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish data stream privilege in seconds. ### Request Example ```php ``` ### Response N/A (This is a client-side SDK usage example) ### Response Example N/A ``` -------------------------------- ### Node.js RTC Token Generation Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Examples of generating RTC tokens in Node.js using the RtcTokenBuilder. ```APIDOC ## Node.js RTC Token Generation ### Description This section demonstrates how to generate Agora RTC tokens using Node.js. It covers building tokens with both integer user IDs (uid) and string user accounts, and includes options for setting specific privilege expiration times. ### Method N/A (Client-side SDK usage) ### Endpoint N/A (Client-side SDK usage) ### Parameters - `appId` (string) - Required - Your Agora Application ID. - `appCertificate` (string) - Required - Your Agora Application Certificate. - `channelName` (string) - Required - The name of the channel. - `uid` (integer) - Required - The user ID for the token. - `account` (string) - Required - The user account for the token. - `role` (enum) - Required - The role of the user (e.g., PUBLISHER, SUBSCRIBER). - `tokenExpirationInSecond` (integer) - Required - The expiration time for the token in seconds. - `privilegeExpirationInSecond` (integer) - Optional - The expiration time for general privileges in seconds. - `joinChannelPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the join channel privilege in seconds. - `pubAudioPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish audio privilege in seconds. - `pubVideoPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish video privilege in seconds. - `pubDataStreamPrivilegeExpireInSeconds` (integer) - Optional - The expiration time for the publish data stream privilege in seconds. ### Request Example ```javascript const RtcTokenBuilder = require("../src/RtcTokenBuilder2").RtcTokenBuilder; const RtcRole = require("../src/RtcTokenBuilder2").Role; const appId = process.env.AGORA_APP_ID; const appCertificate = process.env.AGORA_APP_CERTIFICATE; const channelName = "7d72365eb983485397e3e3f9d460bdda"; const uid = 2882341273; const account = "2882341273"; const role = RtcRole.PUBLISHER; const tokenExpirationInSecond = 3600; const privilegeExpirationInSecond = 3600; const joinChannelPrivilegeExpireInSeconds = 3600; const pubAudioPrivilegeExpireInSeconds = 3600; const pubVideoPrivilegeExpireInSeconds = 3600; const pubDataStreamPrivilegeExpireInSeconds = 3600; // Build token with uid const tokenWithUid = RtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, role, tokenExpirationInSecond, privilegeExpirationInSecond); console.log("Token with int uid:", tokenWithUid); // Build token with user account const tokenWithUserAccount = RtcTokenBuilder.buildTokenWithUserAccount( appId, appCertificate, channelName, account, role, tokenExpirationInSecond, privilegeExpirationInSecond ); console.log("Token with user account:", tokenWithUserAccount); // Build token with uid and specific privileges const tokenWithUidAndPrivilege = RtcTokenBuilder.buildTokenWithUidAndPrivilege( appId, appCertificate, channelName, uid, tokenExpirationInSecond, joinChannelPrivilegeExpireInSeconds, pubAudioPrivilegeExpireInSeconds, pubVideoPrivilegeExpireInSeconds, pubDataStreamPrivilegeExpireInSeconds ); console.log("Token with int uid and privilege:", tokenWithUidAndPrivilege); // Build token with user account and specific privileges const tokenWithUserAccountAndPrivilege = RtcTokenBuilder.BuildTokenWithUserAccountAndPrivilege( appId, appCertificate, channelName, account, tokenExpirationInSecond, joinChannelPrivilegeExpireInSeconds, pubAudioPrivilegeExpireInSeconds, pubVideoPrivilegeExpireInSeconds, pubDataStreamPrivilegeExpireInSeconds ); console.log("Token with user account and privilege:", tokenWithUserAccountAndPrivilege); ``` ### Response N/A (This is a client-side SDK usage example) ### Response Example N/A ``` -------------------------------- ### Generate RTC Token with Sample Code (Go) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Instructions on how to build and run the Go sample code to generate an RTC token. ```APIDOC ## Generate a token with the sample code This section takes `RtcTokenBuilder` as an example to show how to generate a token with the sample code. Before proceeding, ensure that you have installed the latest version of Golang. 1. Download or clone the [Tools](https://github.com/AgoraIO/Tools) repository. 2. Open the `DynamicKey/AgoraDynamicKey/go/sample/RtcTokenBuilder/sample.go` file, replace the value of `appID`, `appCertificate`, `channelName`, and `uid` with your own, and comment out the code snippets of `buildTokenWithUserAccount`. 3. Open your Terminal, navigate to the same directory that holds `sample.go`, and run the following command. After that, an executable file `RtcTokenBuilder` appears in the folder: ``` go build ``` 4. Run the following command. Your token is generated and printed in your Terminal window: ``` ./RtcTokenBuilder ``` ``` -------------------------------- ### Build and Run Go Token Generator Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/go/README.md Commands to compile and execute the Go sample code for generating Agora RTC tokens. Ensure the sample.go file is configured with your specific App ID and Certificate before running. ```bash go build ./RtcTokenBuilder ``` -------------------------------- ### Deploy Token Server with Docker Source: https://context7.com/agoraio/tools/llms.txt Provides a containerized approach to deploying an Agora token generation server. Includes both manual build commands and a docker-compose configuration. ```yaml version: '3' services: token-server: build: . ports: - "8080:8080" environment: - AGORA_APP_ID=${AGORA_APP_ID} - AGORA_APP_CERTIFICATE=${AGORA_APP_CERTIFICATE} ``` ```bash docker build -t agora-token-server . docker run -p 8080:8080 -e AGORA_APP_ID=your_app_id -e AGORA_APP_CERTIFICATE=your_certificate agora-token-server ``` -------------------------------- ### Configure and Run Golem Channel Simulation Source: https://context7.com/agoraio/tools/llms.txt Golem simulates fake users in Agora channels using YUV video and PCM audio files. The configuration requires an App ID and channel details, while the execution requires setting the library path. ```json { "key": "your_agora_app_id", "channel_name": "test-channel", "uid": 12345, "video_file": "/path/to/video.yuv", "audio_file": "/path/to/audio.pcm", "video_profile": 30 } ``` ```bash export LD_LIBRARY_PATH=/path/to/Golem/libs:$LD_LIBRARY_PATH python ./golem_run.py ``` -------------------------------- ### Generate Education Service Tokens Source: https://context7.com/agoraio/tools/llms.txt Generates authentication tokens for Agora Flexible Classroom, including room-specific user tokens and general user tokens. ```python from src.EducationTokenBuilder2 import EducationTokenBuilder room_user_token = EducationTokenBuilder.build_room_user_token(app_id, app_certificate, "room_uuid", "user_uuid", 1, 3600) user_token = EducationTokenBuilder.build_user_token(app_id, app_certificate, "user_uuid", 3600) ``` ```java import io.agora.education.EducationTokenBuilder2; EducationTokenBuilder2 builder = new EducationTokenBuilder2(); String roomUserToken = builder.buildRoomUserToken(appId, appCertificate, "room_uuid", "user_uuid", 1, 3600); String userToken = builder.buildUserToken(appId, appCertificate, "user_uuid", 3600); ``` -------------------------------- ### Generate C++ AccessToken (v007) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides C++ code samples for generating RTC and RTM AccessTokens using version 007 of the token builder. These tokens encapsulate various privileges for Agora services. ```cpp /* * This file is part of the Agora SDK. * Copyright (C) 2019 Agora IO */ #include "RtcTokenBuilder2.h" #include "RtmTokenBuilder2.h" #include #include int main(int argc, char **argv) { std::string appID = "YOUR_APP_ID"; std::string appCertificate = "YOUR_APP_CERTIFICATE"; std::string channelName = "YOUR_CHANNEL_NAME"; std::string uid = "123"; uint32_t expirationTimeInSeconds = 600; uint32_t joinChannelTime = 0; // Build RTC token std::string rtcToken = RtcTokenBuilder2::buildTokenWithUid(appID, appCertificate, channelName, uid, RtcTokenBuilder2::Role_App_Admin, expirationTimeInSeconds); std::cout << "Rtc Token: " << rtcToken << std::endl; // Build RTM token std::string rtmToken = RtmTokenBuilder2::buildToken(appID, appCertificate, uid, RtmTokenBuilder2::Role_Rtm_User, expirationTimeInSeconds); std::cout << "Rtm Token: " << rtmToken << std::endl; return 0; } ``` -------------------------------- ### AgoraRTC.checkSystemRequirements Source: https://github.com/agoraio/tools/blob/master/TroubleShooting/Agora-WebRTC-Troubleshooting/README.md Checks if the current browser environment supports the Agora Web SDK. ```APIDOC ## AgoraRTC.checkSystemRequirements ### Description Verifies if the browser environment meets the requirements for the Agora Web SDK. ### Method Synchronous Function ### Parameters None ### Response - **boolean** - Returns true if the browser is supported, false otherwise. ``` -------------------------------- ### Connection Quality Testing Source: https://github.com/agoraio/tools/blob/master/TroubleShooting/Agora-WebRTC-Troubleshooting/README.md Establishes a sender and receiver client to publish and subscribe to a stream, then retrieves connection statistics using getStats. ```javascript const stream = AgoraRTC.createStream(); stream.getStats((stats) => { console.log(stats); }); ``` -------------------------------- ### Run PHP RTC Token Generator Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/php/README.md Executes the PHP sample script to generate an Agora RTC token. Requires the user to configure the appID, appCertificate, channelName, and uid within the RtcTokenBuilderSample.php file before execution. ```bash php RtcTokenBuilderSample.php ``` -------------------------------- ### Generate Go AccessToken (v006) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides Go code samples for generating RTC and RTM AccessTokens using version 006 of the token builder. These tokens are used for authentication in older Agora SDK versions. ```go package main import ( "fmt" "github.com/AgoraIO/Tools/DynamicKey/AgoraDynamicKey/go/src/RtcTokenBuilder" "github.com/AgoraIO/Tools/DynamicKey/AgoraDynamicKey/go/src/RtmTokenBuilder" ) func main() { appID := "YOUR_APP_ID" appCertificate := "YOUR_APP_CERTIFICATE" channelName := "YOUR_CHANNEL_NAME" uid := "123" expirationTimeInSeconds := uint32(600) // Build RTC token rtcToken := RtcTokenBuilder.RtcTokenBuilder.buildToken(appID, appCertificate, channelName, uid, expirationTimeInSeconds) fmt.Printf("RTC Token: %s\n", rtcToken) // Build RTM token rtmToken := RtmTokenBuilder.RtmTokenBuilder.buildToken(appID, appCertificate, uid, expirationTimeInSeconds) fmt.Printf("RTM Token: %s\n", rtmToken) } ``` -------------------------------- ### Generate Go AccessToken (v007) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides Go code samples for generating RTC and RTM AccessTokens using version 007 of the token builder. These tokens are essential for secure authentication with Agora services. ```go package main import ( "fmt" "github.com/AgoraIO/Tools/DynamicKey/AgoraDynamicKey/go/src/rtctokenbuilder2" "github.com/AgoraIO/Tools/DynamicKey/AgoraDynamicKey/go/src/rtmtokenbuilder2" ) func main() { appID := "YOUR_APP_ID" appCertificate := "YOUR_APP_CERTIFICATE" channelName := "YOUR_CHANNEL_NAME" uid := "123" expirationTimeInSeconds := uint32(600) // Build RTC token rtcToken, err := rtctokenbuilder2.BuildTokenWithUid(appID, appCertificate, channelName, uid, rtctokenbuilder2.RoleAdmin, expirationTimeInSeconds) if err != nil { fmt.Printf("Error building RTC token: %v\n", err) } else { fmt.Printf("RTC Token: %s\n", rtcToken) } // Build RTM token rtmToken, err := rtmtokenbuilder2.BuildToken(appID, appCertificate, uid, rtmtokenbuilder2.RoleRtmUser, expirationTimeInSeconds) if err != nil { fmt.Printf("Error building RTM token: %v\n", err) } else { fmt.Printf("RTM Token: %s\n", rtmToken) } } ``` -------------------------------- ### Generate C++ AccessToken (v006) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides C++ code samples for generating RTC and RTM AccessTokens using version 006 of the token builder. These tokens are used for authentication in older Agora SDK versions. ```cpp /* * This file is part of the Agora SDK. * Copyright (C) 2019 Agora IO */ #include "RtcTokenBuilder.h" #include "RtmTokenBuilder.h" #include #include int main(int argc, char **argv) { std::string appID = "YOUR_APP_ID"; std::string appCertificate = "YOUR_APP_CERTIFICATE"; std::string channelName = "YOUR_CHANNEL_NAME"; std::string uid = "123"; uint32_t expirationTimeInSeconds = 600; // Build RTC token std::string rtcToken = RtcTokenBuilder::buildToken(appID, appCertificate, channelName, uid, expirationTimeInSeconds); std::cout << "Rtc Token: " << rtcToken << std::endl; // Build RTM token std::string rtmToken = RtmTokenBuilder::buildToken(appID, appCertificate, uid, expirationTimeInSeconds); std::cout << "Rtm Token: " << rtmToken << std::endl; return 0; } ``` -------------------------------- ### Parse Agora Token (Command Line) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md A command-line tool to parse an Agora token. It accepts the token as a command-line argument. ```bash Usage # python3 parse.py YOUR_TOKEN OR # make parse token=YOUR_TOKEN ``` -------------------------------- ### Generate RTC Token with Python Sample Code Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/python/README.md This snippet demonstrates how to generate an RTC token using the provided Python sample code. It requires the Agora SDK, app ID, app certificate, channel name, and user ID. The output is the generated token printed to the console. ```python from AgoraDynamicKey.python.src.RtcTokenBuilder import RtcTokenBuilder # Example values - replace with your own appID = "YOUR_APP_ID" appCertificate = "YOUR_APP_CERTIFICATE" channelName = "YOUR_CHANNEL_NAME" uid = "YOUR_USER_ID" # Build the token token = RtcTokenBuilder.buildTokenWithUid(appID, appCertificate, channelName, uid, RtcTokenBuilder.Role.Role_Publisher, 0, 0) print(f"Generated RTC Token: {token}") ``` ```bash python RtcTokenBuilderSample.py ``` -------------------------------- ### Construct Custom Tokens with AccessToken2 Source: https://context7.com/agoraio/tools/llms.txt Provides low-level control to build tokens by manually adding specific services like RTC and RTM with custom privileges. ```cpp #include "AccessToken2.h" using namespace agora::tools; AccessToken2 token(appId, appCertificate, 0, 3600); std::unique_ptr rtcService(new ServiceRtc(channelName, uid)); rtcService->AddPrivilege(ServiceRtc::kPrivilegeJoinChannel, 3600); token.AddService(std::move(rtcService)); std::string tokenString = token.Build(); ``` ```javascript const { AccessToken2, ServiceRtc, ServiceRtm } = require("./src/AccessToken2"); const token = new AccessToken2(appId, appCertificate, 0, 3600); const rtcService = new ServiceRtc(channelName, uid); token.addService(rtcService); const tokenString = token.build(); ``` -------------------------------- ### Generate Python AccessToken (v007) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides Python code samples for generating RTC and RTM AccessTokens using version 007 of the token builder. These tokens ensure secure access to Agora's real-time communication services. ```python from RtcTokenBuilder2 import RtcTokenBuilder from RtmTokenBuilder2 import RtmTokenBuilder appId = 'YOUR_APP_ID' appCertificate = 'YOUR_APP_CERTIFICATE' channelName = 'YOUR_CHANNEL_NAME' uid = '123' expirationTimeInSeconds = 600 # Build RTC token rtc_token = RtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, RtcTokenBuilder.Role.ADMIN, expirationTimeInSeconds) print(f'RTC Token: {rtc_token}') # Build RTM token rtm_token = RtmTokenBuilder.buildToken(appId, appCertificate, uid, RtmTokenBuilder.Role.RTM_USER, expirationTimeInSeconds) print(f'RTM Token: {rtm_token}') ``` -------------------------------- ### Check Browser Compatibility Source: https://github.com/agoraio/tools/blob/master/TroubleShooting/Agora-WebRTC-Troubleshooting/README.md Uses the AgoraRTC SDK to verify if the current browser environment meets the requirements for WebRTC functionality. ```javascript AgoraRTC.checkSystemRequirements(); console.log(navigator.appVersion); console.log(navigator.appName); ``` -------------------------------- ### Generate Agora RTC Token via Python Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/python3/README.md This snippet demonstrates how to execute the RtcTokenBuilderSample script. It requires configuring your App ID, App Certificate, channel name, and UID within the script before execution. ```bash python RtcTokenBuilderSample.py ``` ```bash python -V ``` -------------------------------- ### Configure Nginx and TURN for WebRTC Proxy Source: https://context7.com/agoraio/tools/llms.txt Sets up reverse proxy endpoints in Nginx for WebRTC traffic and configures a TURN server for relaying media. Requires proper domain and SSL certificate management. ```nginx location /ap/ { proxy_pass https://ap-web-1.agora.io/; } location /cs/ { proxy_pass https://webrtc2-ap-web-1.agora.io/; } location /rs/ { proxy_pass https://report-edge.agora.io/; } location /ws/ { proxy_pass https://miniapp.agoraio.cn/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } ``` ```bash extIP=your_external_ip udpport=3478 tcpport=3433 realm=agora.io ``` -------------------------------- ### Generate Python AccessToken (v006) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides Python code samples for generating RTC and RTM AccessTokens using version 006 of the token builder. These tokens are used for authentication in older Agora SDK versions. ```python from RtcTokenBuilder import RtcTokenBuilder from RtmTokenBuilder import RtmTokenBuilder appId = 'YOUR_APP_ID' appCertificate = 'YOUR_APP_CERT_' channelName = 'YOUR_CHANNEL_NAME' uid = '123' expirationTimeInSeconds = 600 # Build RTC token rtc_token = RtcTokenBuilder.buildToken(appId, appCertificate, channelName, uid, expirationTimeInSeconds) print(f'RTC Token: {rtc_token}') # Build RTM token rtm_token = RtmTokenBuilder.buildToken(appId, appCertificate, uid, expirationTimeInSeconds) print(f'RTM Token: {rtm_token}') ``` -------------------------------- ### Configure Agora.io Vendor Credentials Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/nodejs/server/README.md Updates the DemoServer.js file with your specific Agora App ID and App Certificate. These credentials are required for the server to authenticate and generate tokens. ```javascript var appID = ""; var appCertificate = ""; ``` -------------------------------- ### Generate Java AccessToken (v007) Source: https://github.com/agoraio/tools/blob/master/DynamicKey/AgoraDynamicKey/README.md Provides Java code samples for generating RTC and RTM AccessTokens using version 007 of the token builder. These tokens are crucial for securing communication within Agora applications. ```java import io.agora.rtc.RtcTokenBuilder; import io.agora.rtm.RtmTokenBuilder; public class TokenGenerator { public static void main(String[] args) { String appId = "YOUR_APP_ID"; String appCertificate = "YOUR_APP_CERTIFICATE"; String channelName = "YOUR_CHANNEL_NAME"; String uid = "123"; int expirationTimeInSeconds = 600; // Build RTC token RtcTokenBuilder rtcTokenBuilder = new RtcTokenBuilder(); String rtcToken = rtcTokenBuilder.buildTokenWithUid(appId, appCertificate, channelName, uid, RtcTokenBuilder.Role.ADMIN, expirationTimeInSeconds); System.out.println("RTC Token: " + rtcToken); // Build RTM token RtmTokenBuilder rtmTokenBuilder = new RtmTokenBuilder(); String rtmToken = rtmTokenBuilder.buildToken(appId, appCertificate, uid, RtmTokenBuilder.Role.RTM_USER, expirationTimeInSeconds); System.out.println("RTM Token: " + rtmToken); } } ```