Skip to content

Pankajg123/agora-token-service

Repository files navigation

Agora Token Webservice

Go Docker Image CI

Written in Golang, using Gin framework to create a RESTful webservice for generating user tokens for use with the Agora.io platform.

Agora Advanced Guide: Token Management.

Deploy to Railway.app

Deploy on Railway

Deploy to Render

Deploy to Render

Deploy to Heroku

Deploy

How to Run

Set the APP_ID and APP_CERTIFICATE env variables.

cp .env.example .env
go run cmd/main.go

Without using .env, you can also set the environment variables as such:

APP_ID=app_id APP_CERTIFICATE=app_cert go run cmd/main.go

The pre-compiled binaries are also available in releases.

Docker

#1. To build the container, with app id and certificate:

docker build -t agora-token-service --build-arg APP_ID=$APP_ID APP_CERTIFICATE=$APP_CERTIFICATE .

#2. Run the container

docker run agora-token-service

Note: for testing locally

docker run -p 8080:8080 agora-token-service

Endpoints

Ping

endpoint structure

/ping

response:

{"message":"pong"} 

RTC Token

The rtc token endpoint requires a tokenType (uid || userAccount), channelName, and the user's uid (type varies based on tokenType). expiry(optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rtc/:channelName/:role/:tokenType/:rtcuid/?expiry=3600

response:

{"rtcToken":" "} 

RTM Token

The rtm token endpoint requires the user's rtmuid. expiry(optional) Pass an integer to represent the privelege lifetime in seconds. endpoint structure

/rtm/:rtmuid/?expiry=3600

response:

{"rtmToken":" "} 

Both Tokens

The rte token endpoint generates both the rtc and rtm tokens with a single request. This endpoint requires a tokenType (uid || userAccount), channelName, the user's rtcuid (type varies String/Int based on tokenType) and rtmuid which is a String. Omitting rtmuid will assume it's the same as rtcuid. expiry(optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rte/:channelName/:role/:tokenType/:rtcuid/:rtmuid/?expiry=3600

response:

{
  "rtcToken":"rtc-token-djfkaljdla",
  "rtmToken":"rtm-token-djfkaljdla" 
} 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published