> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Secure video playback

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

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](/docs/getting-started/activate-your-account) 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](/docs/video-security/generate-jwts-for-secure-media).

## Secure on-demand playback

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

```swift
// Play an on-demand video with a token
playerViewController.prepare(
    playbackID: playbackID,
    playbackOptions: PlaybackOptions(playbackToken: playbackToken)
)
```

## Secure live stream playback

For live streams, include both the `streamType` and `playbackToken`:

```swift
// Play a live stream with a token
playerViewController.prepare(
    playbackID: playbackID,
    playbackOptions: PlaybackOptions(
        streamType: "live",
        playbackToken: playbackToken
    )
)
```

## What's next

* [Play DRM-protected content](/docs/ios-player/play-drm-protected-content) for FairPlay DRM encryption.
* [Handle playback errors](/docs/ios-player/handle-playback-errors) for troubleshooting token issues.