Secure video playback

Learn how to protect private video content in the FastPix iOS Player using token-based authentication.

To control access to private media content, the FastPix iOS Player supports token-based authentication for both on-demand and live streams. Tokens ensure that only authorized users can view protected content.

Security best practices

When securing private media streams, follow these practices:

  • Access private media using dynamically generated, short-lived playback IDs tied to the user’s authenticated session.
  • Authenticate users (for example, using OAuth or JWT) before granting access to private media.
  • Always use HTTPS for API calls and media streams to prevent interception.
  • Generate signed tokens for playback IDs that are valid only for a limited time and associated with a specific user session.

How access tokens work

Access tokens are short-lived credentials that authenticate a user’s right to view content. When a user requests a stream, the player sends the token to verify authorization.

The token workflow:

  1. Generate the token server-side after the user authenticates. The token includes a signature and expiration date (for example, 1 hour). See how to generate access tokens for details.
  2. Pass the token to the player along with the playback ID when configuring playback.

For a detailed guide on JWT token generation, see Secure playback with JWTs.

Secure on-demand playback

Pass the playbackToken in PlaybackOptions to secure an on-demand stream:

1// Play an on-demand video with a token
2playerViewController.prepare(
3 playbackID: playbackID,
4 playbackOptions: PlaybackOptions(playbackToken: playbackToken)
5)

Secure live stream playback

For live streams, include both the streamType and playbackToken:

1// Play a live stream with a token
2playerViewController.prepare(
3 playbackID: playbackID,
4 playbackOptions: PlaybackOptions(
5 streamType: "live",
6 playbackToken: playbackToken
7 )
8)

What’s next