When using the Stream Mobile SDKs, two authentication layers exist:
- Embed View Token Authentication: controls access to the video
- CDN Token Authentication: protects delivery from Bunny CDN and is handled automatically by the SDK
This document focuses on Embed View Token Authentication, which must be handled by a customer-managed backend or Edge Script containing custom business logic that decides whether a certain client is allowed to play back a video by returning an embedded view token.
Embed View Token Authentication
Purpose
- Authorizes a viewer to play a specific video
- Enforced at the Stream API level
- Required for private or restricted videos
Mobile SDK Responsibility
- The customer backend generates the token
- The mobile app requests the token and passes it to the SDK player element
- The SDK uses the token for playback; CDN token signing happens automatically
Supported Authentication Methods
Backend Requirements
The backend (or Edge Script) must:
-
Securely store the Video Library API Key as it serves as a secret that must not be stored in the mobile app
-
Authenticate the mobile app user with custom business logic
-
Generate embed view token by following the token authentication signing procedure (token security key is your Video Library API Key)
-
Return a
token and expires values in response:
Tokens should be short-lived (1–5 minutes recommended), unless you have a specific use-case for which longer expiration could be used.
Edge Script Example
Below is an example Edge Script that generates embed view tokens. Store VIDEO_LIBRARY_API_KEY as an Edge Script Secret.
Android SDK Usage
The PlayVideo call supports token parameters:
Flow:
- Request embed token from backend
- Receive
{ token, expires }
- Pass values to
PlayVideo
iOS SDK Usage
The BunnyStreamPlayer initializer supports token parameters:
Flow:
- Request embed token from backend
- Receive
{ token, expires }
- Initialize player with token data
Important Notes
- The Video Library API Key must never be included in mobile apps
- Embed View Token Authentication is required if you don’t want to publicly expose your videos
- CDN Token Authentication is applied to CDN URLs automatically if turned on in the video library
Last modified on May 19, 2026