GithubHelp home page GithubHelp logo

agora-token-service's Introduction

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" 
} 

agora-token-service's People

Contributors

digitallysavvy avatar maxxfrazer avatar mupati avatar ekaansharora avatar akshatvg avatar

Watchers

Anderson Stühler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.