NEWDolby Media Processing APIs are now the Dolby.io Media APIs Learn More >
X

Authentication

To make any API call to https://api.dolby.com/media your request must first be authenticated. You get a unique API key assigned to you for each application associated with your developer account. Whenever you process media you will be charged minutes against this key so it is important that you protect your credentials.

The Media APIs support two authentication types:

  • API Key Authentication
  • OAuth Bearer Token Authentication

❗️

Protect Your API Key

You should take precautions to protect your API Key and keep it private. A common error is to store a key as a variable in client code such as JavaScript or mobile apps that can be stolen. If you suspect your key is at risk, you can generate a new application and key from the Dolby.io dashboard or contact support for help.

API Key Authentication

For this method of authentication, you will pass your credentials as the x-api-key header with every request. This is the simplest approach to authentication and can work well for testing or code that runs in a protected environment.

Step 1: Get your API key

Log into your developer account and access the dashboard.

Step 2: Call Media APIs with x-api-key header

To use the API key, include the key in a header called x-api-key as part of any requests. It might look like this:

curl -X GET https://api.dolby.com/media/status \
       --header "x-api-key: $DOLBYIO_API_KEY"

OAuth Bearer Token Authentication

For OAuth, you need to generate an access token using your API key and secret before calling any of the Media APIs. This encrypted token is then passed in as a header. New tokens can be created as needed to help protect your API key.

Step 1. Get your API key and secret

When you create a developer account you will be assigned an API key and an API secret. These can be found on your dashboard. The key and secret pair is a unique identifier that is assigned just to you. You'll want to keep this credential secret for any applications you create.

Step 2. Encrypt your credentials

Concatenate the API key and API secret separated with a colon ":" and then encode with Base64.

For example, if your API key is abcdefghABCDEFGHabcdef== and secret is 12345678abcdefgh=.

$ export BASE64_KEY_SECRET=`echo -n "abcdefghABCDEFGHabcdef==:12345678abcdefgh=" | base64`
YWJjZGVmZ2hBQkNERUZHSGFiY2RlZj09OjEyMzQ1Njc4YWJjZGVmZ2g9

Step 3. Generate an access token

Call https://api.dolby.com/media/oauth2/token to get an access token. The token generation endpoint requires the API secret encoded to Base64 encoded to Base64 in an Authorization header as the Basic type.

curl -X POST 'https://api.dolby.com/media/oauth2/token' \
      --header 'Authorization: Basic $BASE64_KEY_SECRET' \
      --header 'Content-Type: application/x-www-form-urlencoded' \
      --data 'grant_type=client_credentials'
import requests
from requests.auth import HTTPBasicAuth

key = "abcdefghABCDEFGHabcdef=="
secret = "abcdefghABCDEFGHabcdefgh12345678abcdefgh="
response = requests.post("https://api.dolby.com/media/oauth2/token",
    auth = HTTPBasicAuth(key, secret),
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    },
    data= { "grant_type": "client_credentials" })
response.raise_for_status()
print(response.json()["access_token"])
const axios = require('axios').default;

const key = process.env.DOLBYIO_API_KEY;
const secret = process.env.DOLBYIO_API_SECRET;
const basic_credentials = btoa(`${key}:${secret}`);

// For Node environments you'd handle credentials like this:
// const basic_credentials = new Buffer.from(`${key}:${secret}`).toString('base64');

const params = new URLSearchParams();
params.append('grant_type', 'client_credentials');

const config = {
    method: 'post',
    url: 'https://api.dolby.com/media/oauth2/token',
    headers: {
      'Authorization': `Basic ${basic_credentials}`,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: params
  };

axios(config)
    .then(function (response) {
      console.log(response.data.access_token);
    })
    .catch(function (error) {
      console.log(error);
    });

The endpoint returns an access token in the JSON Web Token (JWT) format.

Step 4. Call Media APIs with Authorization header

Include the access token from the previous step in an Authorization header with Bearer type.

curl -X GET https://api.dolby.com/media/status \
       --header "Authorization: Bearer $DOLBYIO_ACCESS_TOKEN"
import requests

response = requests.post("https://api.dolby.com/media/enhance",
    headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer " + access_token
    },
    data= { "input": "https://sample.com/input.wav", "output": "https://sample.com/output.wav" })
response.raise_for_status()
print(response.json()["job_id"])
const axios = require('axios').default;

const config = {
    method: 'post',
    url: 'https://api.dolby.com/media/enhance',
    headers: {
      'Authorization': `Bearer ${access_token}`,
      'Content-Type': 'application/json'
    },
    data: { input: 'https://sample.com/input.wav', output: 'https://sample.com/output.wav' }
  };

axios(config)
    .then(function (response) {
      console.log(response.data.job_id);
    })
    .catch(function (error) {
      console.log(error);
    });

API Reference


Did this page help you?