How to do Authentication while playing The Video

I have used AES Clear Key and Widevine DRM. Please see the following Code.

private Task CreateDrmConfig(Models.Encoding encoding, Muxing muxing, Output output,
string outputPath)
{
var widevineDrm = new CencWidevine()
{
Pssh = “AAAAIHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAA=”
};

        var cencDrm = new CencDrm()
        {
            Outputs = new List<EncodingOutput>() { BuildEncodingOutput(output, outputPath) },
            Key = _configProvider.GetDrmKey(),
            Kid = _configProvider.GetDrmWidevineKid(),
            Widevine = widevineDrm

        };

This is my player file.
https://bitmovinoutputdata.blob.core.windows.net/clearkey/Player.html

I have to validate the user through a JWT token or OTP. How I can achieve that.
Currently, this HTML URL has no security; anyone can play the file because an encrypted key is inside the HTML file. I want to give access to the video for limited time. Is this possible?

@rajesh.rai Yes, agree. The keys should not be hardcoded in the HTML file. You should have a backend service to validate the user and then return the tokens via an HTTP call, which you should then pass to the player configuration.

Hi Kishore, Thanks for your prompt response. Even though your key is static for that title or video. If you want to change the key, we need to encode that asset with a new key.
Is there any way that we can change the key without the encoding?

@rajesh.rai It is not possible to change the key after encoding. You have to use DRMs like Widevine or Fairplay, which supports key rotation, and the player will handle it out of the box.

More information about Licence servers can be found on this page -

Hi Kishore,
Thanks for your prompt response.
I am already using Widevine and PlayReady DRM. Please see the following code in C#.

private Task CreateDrmConfig(Models.Encoding encoding, Muxing muxing, Output output,
string outputPath)
{
var widevineDrm = new CencWidevine()
{
Pssh = “QWRvYmVhc2Rmc2FkZmFzZg==”,

        };

        var playready = new CencPlayReady()
        {
           
            Pssh = "QWRvYmVhc2Rmc2FkZmFzZg=="
      
        };
       
   
        var cencDrm = new CencDrm()
        {
            Outputs = new List<EncodingOutput>() { BuildEncodingOutput(output, outputPath) },
            Key = _configProvider.GetDrmKey(),
            Kid = _configProvider.GetDrmWidevineKid(),
            Widevine = widevineDrm,
            PlayReady = playready

        };


        return _bitmovinApi.Encoding.Encodings.Muxings.Fmp4.Drm.Cenc.CreateAsync(encoding.Id, muxing.Id, cencDrm);
    }

I did not find any sample code to rotate the keys in bitmovin API.

Thanks
Rajesh Rai

Hi @rajesh.rai I checked with the team internally, and it is not currently supported, and key rotation is primarily advised for live streams. I forwarded the details to the Product Owner, who will add it to the roadmap based on market demand and feedback from other customers.

If you want to change the keys, you’ll have to re-encode the content with different keys for now.

Please also keep an eye on our Product Release pages for Player, Encoding and Analytics for new updates, as the product teams regularly make updates and release features that might be relevant to you.

Hi Kishore.
Thanks for your prompt response. In this case, can we use third-party licensing, where we can send custom data that will be validated on our side?