Skip to content

digitallysavvy/agora-token-service

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 61 commits ahead, 126 commits behind AgoraIO-Community:main.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.io Advanced Guide: Token Management

How to Run

Set the APP_ID and APP_CERT env variables.

go run main.go

Docker

#1. Open the Dokerfile and update the values for APP_ID and APP_CERT

ENV APP_ID=""
ENV APP_CERTIFICATE=""

#2. To build the container:

docker build -t agora-token-service .

#3. 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). (optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rtc/:channelName/:role/:tokentype/:uid/?expireTime

response:

{"rtcToken":" "} 

RTM Token

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

/rtm/:uid/?expireTime

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, and the user's uid (type varies String/Int based on tokentype). (optional) Pass an integer to represent the token lifetime in seconds.

endpoint structure

/rte/:channelName/:role/:tokentype/:uid/?expireTime

response:

{
  "rtcToken":" ",
  "rtmToken":" " 
} 

About

an Agora Token Server using Golang & Gin to run as a webservice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 89.5%
  • Dockerfile 10.5%