Deploy a middleware server
To streamline the use of token authentication and RESTful APIs within your infrastructure, Agora’s developer community offers the open-source Agora Go Backend Middleware. The backend provides RESTful APIs for tasks such as token generation, cloud recording management, and real-time transcription. This guide shows you how to implement a token server using the community middleware.
Understand the tech
The following figure illustrates the architecture of the middleware token generation micro service.
Set up and run the Go backend middleware
Take the following steps to set up and run the middleware project:
-
Clone the repository
-
Install dependencies
Ensure you have Go installed on your system. Navigate to the project directory and install the project dependencies: -
Configure environment variables
-
Copy the example
.env
file. -
Update the following variables in the
.env
file:APP_ID
: Your Agora App ID.APP_CERTIFICATE
: Your Agora App Certificate.
-
-
Run the middleware:
Start the middleware server using the following command:
The middleware runs on the default port, for example
localhost:8080
.
Generate tokens
Refer to the following curl
example to test the middleware's token generation API endpoint.
The command-line examples in this guide are for demonstration purposes only. Do not use them directly in a production environment. Implement RESTful API requests through your application server.
POST: /token/getNew
Replace localhost:8080
with your server's address.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Middleware token generation API
This section provides details about the middleware token generation API endpoints.
Generate Token
Generates a Video SDK, Signaling, or Chat token based on the provided parameters.
Endpoint
POST /token/getNew