Playback tokens (JWT)
A playback token is a signed JSON Web Token (JWT) that lets a player watch specific streams for a limited time. When secure playback is enabled, a player without a valid token can't play the protected streams. This page shows where to create tokens, every option a token can carry, and how to use it in the player.
Before you start
- Secure playback must be enabled, for your whole organisation or for single streams. On for the organisation, every stream needs a token; on for a stream, only that stream does. To protect single streams, contact us. Check it at https://dashboard.nanostream.cloud/organisation under Enabled Packages (Secure). If it shows Upgrade needed, contact us. The Builder Hub account menu also shows Secure playback as On or Off.
- Use a separate organisation for testing, so turning on secure playback doesn't stop your production streams.
- Role:
nanoAdminandnanoUsercan create playback tokens;nanoReadOnlycan't.
Playback tokens are not API credentials. They only authorise playback. To call the nanoStream APIs you use an API key or an access token (bintu token); see APIs & SDKs overview.
Set it up
The Builder Hub is quickest for trying it out, the Dashboard gives you every option in a form for manual tokens and events, and the token API is for production. For production, always create tokens on your backend, per viewer, with the tightest restrictions you can. See Security best practices for a complete backend example.
- Builder Hub
- Dashboard
- API
Who can use it: free account or existing customer, with secure playback on. Guests see token creation marked Sign in and can only run the revocation demo. Without secure playback, the bar reads Secure playback is not on your account yet. with Upgrade.
Open Build › Security › Manage tokens. It has three cards: Create an access token, Create a playback token and Revoke playback tokens.
- Click Create a playback token.
- Under For, pick one of your streams (live ones are marked (live)), or Every stream of your account.
- Under Valid for, choose 1 hour, 24 hours, 7 days or 30 days.
- Optionally enter a Tag, for example
partner-site, to recognise the token later. - Click Create playback token.
What you get: under Your token, the token with Copy (the hub doesn't keep it, so copy it now); a Viewer link that plays the stream with the token; the player code that hands the token to the nanoStream Player (security: { jwtoken: '<the token>' }); and a preview Playing with this token. To create tokens from your own server, use the API tab.
[!WARNING] A token for every stream that leaks plays all of them until it expires. For a live service, create short tokens for one stream on your server and give each viewer their own.
Create an access token is for your server, scripts and dashboards rather than players: it lets them call the nanoStream REST API and the Analytics API instead of your API key.
- Click Create an access token.
- Under Valid for, choose 1 day, 7 days, 30 days, 90 days or 1 year (the maximum).
- Under For, tick the APIs it may call: the bintu API (streams, their settings and states) and the Analytics API (viewers, usage and quality).
- Optionally add a Note, then click Create access token.
You get the token, its expiry and token id, and a ready curl line for each API (header x-bintu-token or x-access-token). Quote the token id to support, never the token. An access token acts as you, with your role, and can't be revoked: pick the shortest expiry that works. If your role can't create tokens with your sign-in alone, the hub asks you to confirm your email and password (Create with my password). Access tokens and API keys are explained in the APIs & SDKs overview.
Revoke playback tokens › Show token revocation demonstrates revocation on our demo stream, guests included. See Token revocation & session control.
| Message | What to do |
|---|---|
| Secure playback is off for … | Your streams play without a token, so there's nothing to create. Click Ask for secure playback to request it. |
| The token could not be created: … | Check that you're signed in with a role that may create tokens (nanoAdmin or nanoUser). |
| Pick at least one API. | Tick the bintu API, the Analytics API, or both. |
| That email and password don't match. | Re-enter your login when confirming your password. |
| A hub player says Secure playback is on, and no playback token could be created. | Sign out and sign in again with an admin login of your organisation. |
Who can use it: any Dashboard login with role nanoAdmin or nanoUser, in an organisation with secure playback on.
- Click the lock icon in the left menu (Secure Playback Token, https://dashboard.nanostream.cloud/secure/token), or Create new token on a stream's overview page. The token form is also available inline on the playout, code snippets and Webcaster pages.
- Choose the Target: Entire Streamgroup, Streamname(s) or Entire Organization.
- Set the Token Lifetime / Expiration Date.
- Optional: Enable Token Revocation, Force Disconnect on Expiration, Not Before Date, Client IP, Domain, UserID, Tag.
- Click Create new token.
What you get: the overview shows the decoded token and a ready-to-copy security object for your player config.
[!WARNING] The Dashboard doesn't store tokens. Once you refresh or leave the page, a token can't be retrieved. Copy it first. Treat organisation-wide tokens as confidential: anyone who has one can watch every stream of your organisation until it expires.
Who can use it: your backend, with an access token (bintu token) or your organisation API key.
- Call
POST https://token.nanostream.cloud/api/v1/splaywith one scope field and an expiry:
curl -X POST https://token.nanostream.cloud/api/v1/splay \
-H "Content-Type: application/json" \
-H "X-BINTU-TOKEN: <YOUR_BINTU_TOKEN>" \
-d '{"groupid": "<STREAM_GROUP_ID>", "exp": <UNIX_SECONDS>}'
- Hand the returned
data.tokento the viewer's player (see Use the token in the player).
What you get: a short-lived token per viewer session. The Token API section below has the headers, every request field, a full example and the response codes.
Token API
POST https://token.nanostream.cloud/api/v1/splay
Content-Type: application/json
X-BINTU-TOKEN: <YOUR_BINTU_TOKEN>
Authenticate with either header:
| Header | Credential | Recommendation |
|---|---|---|
X-BINTU-TOKEN | Access token (bintu token): temporary, role-scoped, can be invalidated | Recommended |
X-BINTU-APIKEY | Organisation API key: permanent, full access | Only on your backend |
EXP=$(( $(date +%s) + 1800 )) # expires in 30 minutes
curl -X POST https://token.nanostream.cloud/api/v1/splay \
-H "Content-Type: application/json" \
-H "X-BINTU-TOKEN: <YOUR_BINTU_TOKEN>" \
-d '{
"groupid": "<STREAM_GROUP_ID>",
"exp": '"$EXP"',
"ip": "203.0.113.10",
"domain": "watch.example.com",
"user": "user-4711",
"tag": "table 7",
"revocable": true,
"forceDisconnect": false
}'
Response:
{
"success": true,
"data": {
"token": "<YOUR_JWT>"
}
}
Full API reference: https://api.nanostream.cloud/docs/token/
Request fields
Include exactly one scope field (groupid, streams or orgawide). Everything else is optional.
| Field | Type | Description |
|---|---|---|
groupid | string | Stream group ID. The token plays every stream (rendition) in the group, so one token covers ABR. |
streams | array of strings | One or more stream names, e.g. ["XXXXX-YYYY1","XXXXX-YYYY2"]. |
orgawide | boolean | true: all streams of your organisation. Avoid in production. |
exp | number | Expiry, UNIX timestamp in seconds. See Lifetime. |
nbf | number | "Not before": the token is invalid before this UNIX timestamp (seconds). |
forceDisconnect | boolean | Default false. true ends active sessions when the token expires. |
revocable | boolean | Default false. true lets you revoke the token; limits lifetime to 24 hours. |
domain | string | Web application domain the player must run on (referrer), e.g. example.domain.com. |
ip | string or array | One IPv4 address or CIDR range ("198.51.100.0/24"), or an array of up to 10 addresses and ranges, mixed. |
user | string | User ID, name or alias for traceability. |
tag | string | Free-text tag, e.g. an event or table. |
cust | string, up to 100 characters | Optional custom text stored in the token, for your own reference. It doesn't restrict playback. |
Response codes
| Code | Meaning | Example body |
|---|---|---|
200 | Token created | {"success": true, "data": {"token": "<YOUR_JWT>"}} |
400 | Parameter missing | {"success": false, "errorCode": 1000, "message": "Parameter required: ..."} |
403 | Credential not valid | {"success": false, "errorCode": 1001, "message": "Provided APIKey is not valid"} |
If your organisation doesn't have secure playback, the token service answers with error code 5003 ("Not a secured organisation").
Lifetime
| Token type | Maximum lifetime | Can be revoked |
|---|---|---|
| Non-revocable (default) | 365 days | No |
Revocable ("revocable": true) | 24 hours | Yes |
| Created in the Builder Hub | The Valid for you pick: 1 hour to 30 days | Yes for 1 hour and 24 hours; no for 7 and 30 days |
Only the revocation demo on Revoke playback tokens uses 5-minute tokens, on nanocosmos's demo stream.
Always set exp yourself. Don't rely on the default lifetime.
We recommend a lifetime of 24 hours or less in general, and 5–30 minutes for high-security use cases. Longer non-revocable tokens can be acceptable for test pages and environments with lower security requirements. The 24-hour maximum for revocable tokens may change in the future.
What happens when a token expires
An expired token can't be used to:
- start playback or reconnect
- switch streams or ABR renditions on an existing connection
Active sessions depend on forceDisconnect:
forceDisconnect | Active sessions after expiry |
|---|---|
false (default) | Keep playing. Only new connections and stream switches are rejected. |
true | Disconnected. |
Token claims
The token service signs the token. When you decode a token (for example in the Dashboard's overview), you see these claims:
| Claim | Meaning |
|---|---|
aud | Audience. splay for playback tokens. |
iss | Issuer: nanocosmos. |
sub | Your organisation ID. |
jti | Unique token ID. Use it to find the token in the Guardian view of nanoStream Analytics. |
iat, nbf, exp | Issued at, not before, expires (UNIX seconds). |
streams | Array of stream names the token may play. |
groupid | Stream group ID, for a group token. |
orgahash | Your organisation's hash, for an organisation-wide token (orgawide: true). |
forceDisconnect, revocable | Session and revocation behaviour. |
tag | Your tag, if set. |
You can check a token with the verify endpoint (no authentication header needed):
curl -X POST https://token.nanostream.cloud/api/v1/splay/verify \
-H "Content-Type: application/json" \
-d '{"token": "<YOUR_JWT>"}'
200 means valid. 403 means invalid, e.g. {"success": false, "errorCode": 1002, "message": "jwt expired"}.
Use the token in the player
Add a security object with jwtoken to the source. With a stream group:
var config = {
source: {
group: {
id: '<STREAM_GROUP_ID>',
security: { jwtoken: '<YOUR_JWT>' }
}
},
playback: { autoplay: true, automute: true, muted: true }
};
With entries (stream names):
var config = {
source: {
defaults: { service: 'bintu' },
entries: [
{
h5live: {
rtmp: { streamname: 'XXXXX-YYYYY' },
security: { jwtoken: '<YOUR_JWT>' }
}
}
]
}
};
You don't need different server URLs for secure playback with the JavaScript player. The player routes to the secure edge when a token is present. In the hosted iframe and demo player, pass the token as group.security.jwtoken=<YOUR_JWT> together with group.id=.
Domain-restricted tokens don't work with the hosted iframe embed. Use the JavaScript API on your own page. See Embed the player.
Use tokens outside the JavaScript player
For external players and native apps, token-protected streams use the secure hosts and the jwtoken query parameter. These URLs are provided as-is, without the player's latency control:
# Low-latency MP4
https://bintu-splay.nanocosmos.de/h5live/authhttp/stream.mp4?url=rtmp://localhost/splay&stream=<STREAM_NAME>&jwtoken=<YOUR_JWT>
# Low-latency HLS (iOS / iPadOS)
https://bintu-splay.nanocosmos.de/h5live/authhttp/playlist.m3u8?url=rtmp://localhost/splay&stream=<STREAM_NAME>&jwtoken=<YOUR_JWT>
IPv4 and IPv6
nanocosmos streaming systems operate over IPv4. Viewers on IPv6 are translated to IPv4 via NAT64, so IP restrictions in tokens use IPv4 addresses. To restrict an IPv6 client, obtain its public IPv4 address (for example with a service such as https://api.ipify.org) and put that address in the token.
Troubleshooting
| Problem | Cause and fix |
|---|---|
| Player error, token "expired" | Create a new token. Check that your server clock is synced (NTP). |
| Token valid, stream doesn't play | Wrong scope (stream not in streams/group), wrong domain, or the viewer's IP doesn't match ip. Decode the token and compare. |
| Token ignored in demo player | The token parameter must match the source form: group.id + group.security.jwtoken. |
| Token has no effect | The organisation isn't secure-enabled, so playback is open anyway. |
403, error code 1001 | API key or access token is invalid, or belongs to another organisation. |
| IP restriction blocks an IPv6 viewer | Use the viewer's public IPv4 address. |
Legacy STS tokens
Before player 4.18.0, secure playback used a proprietary STS token format. STS is deprecated. Use JWT for all new integrations; see Legacy & retired docs if you still maintain an STS setup.
Next steps
- Token revocation & session control
- Security best practices (backend example)
- nanoStream Guardian
- Embed the player
Try it in the Builder Hub: sign in and open Manage tokens to create a playback token for your own stream and watch it play. Start for Free