This server generates secure Agora RTC tokens for video calling applications. It ensures secure authentication, role-based permissions, and token expiration.
- Features
- Setup Instructions
- Installation
- API Endpoints
- Role-Based Permissions
- Logging
- Rate Limiting
- Error Handling
- Sample Integration
- Support
- Secure Authentication: Only authorized users can generate tokens.
- Token Expiration: Tokens expire after 10 hours to prevent misuse.
- Role-Based Permissions: Differentiates between
host
(publisher) andsubscriber
(consumer) roles. - Dynamic Token Generation: Generates tokens on-demand for each request.
- Logging: Logs requests and errors to files.
- Rate Limiting: Limits requests to 100 per 15 minutes per IP address.
- Node.js (v14 or higher)
- MongoDB (local or cloud-based)
- Agora App ID and Certificate (from the Agora Console)
- Clone the Repository:
git clone https://github.com/ZakirCodeArchitect/SRC-Token-server-for-Agora.git cd nodejs-agora-token-server-example
- Installations
npm install
- Setup .env file
APP_ID=YOUR_APP_ID APP_CERTIFICATE=YOUR_APP_CERTIFICATE API_SECRET_KEY=YOUR_SECRET_KEY MONGODB_URI=mongodb://localhost:27017/agora
- Start server
npm start
- API Endpoints
curl -X GET "http://localhost:3000/token-rtc?channelName=test&uid=1234" \ -H "Authorization: YOUR_SECRET_KEY" curl -X GET "http://localhost:3000/host-action?uid=1234" \ -H "Authorization: YOUR_SECRET_KEY" curl -X GET "http://localhost:3000/subscriber-action?uid=5678" \ -H "Authorization: YOUR_SECRET_KEY"