Nearglass

A token for an SDK publisher (nearglass-pub, nearglass.h)

POST
/v1/streams/{id}/publisher-tokens

Authorization

secretKey
headerAuthorizationBearer <token>

sk_...

Path Parameters

id*string

Request Body

application/json
  1. body
ttl?integer

seconds; default 3600. The relay ends a publishing session at expiry: refresh through the token callback

Range1 <= value <= 604800
subject?string

who it is for, in the relay logs as device:; default the stream id

token_id?boolean

give the token an id: one live session at a time, closed when the stream is deleted. Without one (the default) a device can reuse the token across reconnects; a relay scope with require_token_id refuses it

Defaultfalse

Response Body

minted

application/json
  1. response

A token and where to use it; the player and the SDK publisher take it whole.

token?string

the CAT, base64url without padding; CLIENT_SETUP AUTHORIZATION TOKEN type 1

token_id?|

the CWT cti: s-... (viewer), pub-... (SDK publisher asked with token_id), ing-... (gateway), turn: (controller); null for a device publisher token

expires_at?string
Formatdate-time
exp?integer

Unix seconds

relays?array<>
namespace?string
catalog?string
relay_cert_sha256?string

only for a relay with a self-signed certificate

hls?string

the LL-HLS playlist for the player fallback; with the API edge, /v1/play/{id}/hls/index.m3u8 and only for streams with encoder ingest

Example Request
curl -X POST 'https://api.nearglass.com/v1/streams/st_8f2c41d09a7be3105c6e2d77/publisher-tokens' \  -H 'Content-Type: application/json' \  -d '{  "ttl": 3600,  "subject": "camera-7"}'
Example Response
{  "token": "string",  "token_id": "string",  "expires_at": "2019-08-24T14:15:22Z",  "exp": 0,  "relays": [    {      "url": "string"    }  ],  "namespace": "string",  "catalog": "string",  "relay_cert_sha256": "string",  "hls": "string"}