Gate Livepeer streams and assets with JWTs or webhook-based authorisation. Covers signing key creation, JWT generation, and player configuration.
Both access control methods require setting a playbackPolicy on stream or asset creation. Without a playback policy, content is publicly playable by anyone with the playback URL.
Create a signing key pair in Studio under Settings > Signing Keys, or via API:
const signingKey = await client.signingKey.create();// signingKey.privateKey -- base64-encoded private key (save securely, not retrievable later)// signingKey.publicKeyId -- ID to reference in the JWT
Store the private key in your secrets manager. It is shown only once.
import * as Player from '@livepeer/react/player';// Fetch token from your API, then pass to playerexport const GatedPlayer = ({ playbackId, jwt }: { playbackId: string; jwt: string }) => ( <Player.Root src={`https://livepeercdn.studio/hls/${playbackId}/index.m3u8`} jwt={jwt}> <Player.Container> <Player.Video /> </Player.Container> </Player.Root>);
The Player sends the JWT in the Livepeer-Jwt header for WebRTC and HLS requests, and as a jwt query parameter for MP4.For custom players, add the header manually:
// HLS.js with JWT headerconst hls = new Hls({ xhrSetup: (xhr) => { xhr.setRequestHeader('Livepeer-Jwt', jwt); },});