# BuyDRM KeyOS on Web

This article describes how to configure BuyDRM KeyOS DRM with THEOplayer.

Head to our page on [DRM](https://docs-preview.optiview.dolby.com/pr-863/theoplayer/how-to-guides/web/drm/introduction.md) for more general information.

## Integration

We provide open-source DRM integrations which are easy to maintain and allow for a modular approach. You can find them in the [DRM integration samples repository](https://github.com/THEOplayer/samples-drm-integration), alongside guides on how to integrate and use them.

The BuyDRM KeyOS integration can be found [here](https://github.com/THEOplayer/samples-drm-integration/tree/master/web/src/integration/keyos).

## Pre-integration

> **Note**
>
> When integrating DRM for the first time or updating your integration, the DRM integration described above is preferred over the pre-integration below.

Pass your BuyDRM token as `customdata`, and tell THEOplayer that you are using KeyOS. The token is the Authentication XML generated from the BuyDRM platform.

```js
if (HLS) {
  let drmConfiguration = {
    integration: 'keyos',
    customdata: '<CUSTOMDATA>',
    fairplay: {
      licenseAcquisitionURL: '<LICENSE_KEY_URL_FAIRPLAY>',
      certificateURL: '<CERTIFICATE_URL>',
    },
  };
  player.source = {
    sources: {
      src: '<HLS_STREAM_URL>',
      type: 'application/x-mpegurl',
      contentProtection: drmConfiguration,
    },
  };
} else if (DASH) {
  let drmConfiguration = {
    integration: 'keyos',
    customdata: '<CUSTOMDATA>',
    playready: {
      licenseAcquisitionURL: '<LICENSE_KEY_URL_PLAYREADY>',
    },
    widevine: {
      licenseAcquisitionURL: '<LICENSE_KEY_URL_WIDEVINE>',
    },
  };
  player.source = {
    sources: {
      src: '<DASH_STREAM_URL>',
      type: 'application/dash+xml',
      contentProtection: drmConfiguration,
    },
  };
}
```

## Resources

* <https://test.buydrm.com/sites/default/files/pdf/webinar/050217_DeployingKeyOSMulti-DRM_withTHEOPLayer_Webinar.pdf>
* [KeyOS BuyDRM](https://www.buydrm.com/keyosplayer)
* [DRMConfiguration API](https://docs-preview.optiview.dolby.com/pr-863/theoplayer/v11/api-reference/web/interfaces/DRMConfiguration)
