Authenticate and authorize users
Your video content is valuable and only authorized users should be permitted to view it. When a user launches your app, your app must identify the user and the content available to the user. JWP enables you to both identify users and manage their access to your content.
#
PrerequisitesItem | Description |
---|---|
Existing app | App connected to a JWP property The app can also be enabled for web and third-party payments. |
Asset ID & Client ID | IDs that enable access to content when combined:
|
#
Set user authentication and authorizationFollow these steps to enable authentication and authorization for an existing user:
Log in an existing user account by calling
POST /v2/accounts/authenticate
(REST API) orInPlayer.Account.signIn()
(JavaScript).When the request succeeds, JWP returns a unique user authentication token. When the request fails, JWP returns a failure response.
REST API
JavaScript
Validate the user's access by calling
GET /v2/items/jw-media/token?app_config_id={appConfigId}&media_id={mediaId}
(REST API) orcheckAccessForAsset()
(Javascript).If access to the asset is verified, the method returns the content in the response that you can display in your app. If access to the asset cannot be verified, your app should redirect the user to your payment page to re-enter payment details.
REST API
JavaScript
After you have validated the user's access, you can fetch the content by media ID and begin playback.
If you use an app config to manage your content, you can obtain the media ID from the contentId
parameter of the app config URL.
tip
You can add URL signing or digital rights management (DRM) for extra layers of content protection.