How to add token to the video url that can valid for certain time after that user cannot access the content in azure media service which has configured cdn

Boopathi K 0 Reputation points
2023-04-07T12:56:08.0966667+00:00

I want to build a application where user can watch the videos and user can upload it so i want to restrict the other people to acess to other people video how can i do in azure meida service my user data are not in Azure Active directive and i am also using CDN to server the video. what i expect is when user request for the video to my server i need to check does the user have a permission or not once user have i need to genereate the URL that wil valid for only few hours and user can acess the video using the URL how can i do this can anyone guide me ?

Azure Media Services
Azure Media Services
A group of Azure services that includes encoding, format conversion, on-demand streaming, content protection, and live streaming services.
313 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,286 Reputation points
    2023-04-12T23:20:33.1466667+00:00

    Hello @Boopathi K , Thanks for your patience. For this scenario, you can try using Azure Media Services Content Protection to restrict access to the videos. Here are the high-level steps you can follow:

    1. Encode your video content and publish it to your Azure Media Services account.
    2. Create a Content Protection policy that specifies the access control rules for your videos. You can use Azure Media Services REST APIs, Azure Portal, or Azure CLI to create the Content Protection policy.
    3. Use the Content Protection policy to protect your video content. When you apply the Content Protection policy, it generates a protection key and a Content Key ID.
    4. Create a custom authentication and authorization system to validate the user credentials before granting access to the video. This can be implemented using your own authentication system or a third-party authentication provider.
    5. When a user requests to view a video, check their credentials and determine if they have permission to access the video.
    6. If the user has permission, generate a URL with a token that includes the Content Key ID, the protection key, and the expiration time. You can use the Azure Media Services REST API to generate the token.
    7. The user can use the URL with the token to access the video for the specified period.
    8. Configure your CDN to cache the protected video content and serve it to users from the CDN. By using Content Protection with Azure Media Services, you can apply dynamic encryption to your video content and control access to it. Please review the doc for more information: https://video2.skills-academy.com/en-us/azure/media-services/latest/drm-content-protection-concept Hope that helps. Best, -Grace
    0 comments No comments