POST : API to Generate Access Token
POST
https://<appname>.metered.live/api/v1/token
<appname>
- replace it the name of your app.
Description
This endpoint allows you to generate an access Token
Parameters
Parameters | Description | Required | Options | |
---|---|---|---|---|
Query | ||||
secretKey | string | your secret key | yes | - |
Body | application/json | |||
isAdmin | boolean | is this user admin in the meeting. Admin can allow other users without a token in private meetings, and meeting can be create where only admin can broadcast. (share their screen, audio or video) | no | false | true |
roomName | string | name of the room you want to limit the token to | no | - |
globalToken | boolean | create a token that is valid for all the rooms in the app | no | false | true |
name | string | Name of the user. When the user joins the meeting this will be name of the user | no | - |
string | Email you want to set for the user, can be used in your application | no | - | |
meta | string | meta info you want to associate with the participant | no | - |
externalUserId | string | userId you want set for the participant | no | |
expireUnixSec | integer | unix timestamp in seconds. user cannot join the room after this time is reached. | no | - |
notBeforeUnixSec | integer | unix timestamp in seconds. user cannot join the meeting before this time. | no | - |
ejectAfterElapsedTimeInSec | integer | Eject user automatically after the specified seconds. Suppose you want to eject the user automatically after 30 mins then you will set this value to 1800 (30 mins in seconds) | no | - |
joinVideoOn | boolean | iframe only option. | no | false | true |
joinAudioOn | boolean | iframe only option. | no | false | true |
disableVideo | boolean | iframe only option. | no | false | true |
disableAudio | boolean | iframe only option. | no | false | true |
disableScreenSharing | boolean | iframe only option. | no | false | true |
Request Samples
- cURL
- NodeJs
- Ruby
- Python
- Go
cURL
curl --request POST \
--url 'https://appname.metered.live/api/v1/token?secretKey={replace_this_with_your_secretKey}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"globalToken":true}'
NodeJs (Axios)
//We are using axios to send requests in our example: https://axios-http.com
const axios = require('axios');
async function (){
try{
const response = await axios({
method: 'post',
url: 'https://appname.metered.live/api/v1/token',
data: {
globalToken : true
},
params: {
secretKey: 'your_secret_key'
},
})
console.log(response)
} catch(error){
console.log(error)
}
}
Ruby
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://yourapp.metered.live/api/v1/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request.body = "{\"globalToken\":true}"
response = http.request(request)
puts response.read_body
Python
import requests
url = "https://yourapp.metered.live/api/v1/token"
payload = {"globalToken": True}
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
Go
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{"globalToken":true}application/json`)
req, err := http.NewRequest("POST", "https://appname.metered.live/api/v1/token?secretKey={replace_this_with_your_secretKey}", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
Responses
200
{
"token": ""
}
400
{
"success": false,
"message": "Invalid request"
}