Migrate Media Applications to API Token Authentication

The primary change to Dolby.io Media API authentication is a transition from hard-coded API Keys and Access Tokens to API Token authentication. During this migration process, you will create a new App in the Dolby.io developer portal, and get your new App Key and App Secret credentials. Next, you will modify your Dolby.io Media API applications to use your App Key and App Secret to generate an API Token.

🚧

Your existing Dolby.io Media applications will continue to work using API Key or Access Token authentication until December 15 2022. After this date, all Dolby.io Media applications must have migrated to API Token authentication.

📘

Before starting your migration to API Token authentication, you may want to take a look at our Migration tips.

Where can I find the list of Media APIs that have migrated to API Token authentication?

The following list contains the Media APIs that have migrated from using API Keys and Access Tokens to using API Token authentication:

How do I transition from using API Keys?

If your applications use API Keys (deprecated), follow these steps:

1. Locate your App Key and App Secret

Before modifying your applications to generate an API Token, you need credentials to create the API Token. You will need to create a new App in the Dolby.io developer portal to get your new App Key and App Secret credentials. See the Locate your App Key and App Secret procedure before moving on to the next step.

2. Modify your Dolby.io applications

Now that you have your new App Key and App Secret application credentials, we can move on to the next step of modifying your Dolby.io applications to call the Dolby.io Authentication API to get an API Token. Your applications will use this API Token in the Authorization header when accessing all Dolby.io APIs.

The simplest method to migrate from API Keys to Access Tokens is to modify your applications to request an API Token from the Dolby.io Authentication API before every Dolby.io API call. The code examples below show you how to request an API Token.

Code examples

The following examples show you how to create an API Token using your new App Key and App Secret credentials that you created during the Locate your App Key and App Secret procedure.

import requests
import json
import os
APP_KEY = os.environ['APP_KEY']
APP_SECRET = os.environ['APP_SECRET']
payload = { 'grant_type': 'client_credentials', 'expires_in': 1800 }
response = requests.post('https://api.dolby.io/v1/auth/token', data=payload, auth=requests.auth.HTTPBasicAuth(APP_KEY,APP_SECRET))
body = json.loads(response.content)
access_token = body['access_token']
import fetch from 'node-fetch';
 
const auth = Buffer.from(`${process.env.APP_KEY}:${process.env.APP_SECRET}`).toString('base64');
const response = await fetch('https://api.dolby.io/v1/auth/token', {
    method: 'POST',
    body: new URLSearchParams({
        grant_type: 'client_credentials',
        expires_in: 1800
    }),
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Basic ${auth}`
    }
});
const json = await response.json();
const access_token = json.access_token;
AUTH=$(echo $APP_KEY:$APP_SECRET | tr -d '\n' | base64)
curl -X POST  https://api.dolby.io/v1/auth/token -H "Authorization: Basic $AUTH" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=client_credentials&expires_in=1800'

How do I transition from using Access Tokens?

If your applications use Access Tokens (deprecated), follow these steps:

1. Locate your App Key and App Secret

Before modifying your applications to generate an API Token, you need credentials to create the API Token. You will need to create a new App in the Dolby.io developer portal to get your new App Key and App Secret credentials. See the Locate your App Key and App Secret procedure before moving on to the next step.

2. Modify your Dolby.io applications

Now that you have your new App Key and App Secret application credentials, we can move on to the next step of modifying your Dolby.io applications to call the Dolby.io Authentication API to get an API Token. Your applications will use this API Token in the Authorization header when accessing all Dolby.io APIs.

First, you need to replace the deprecated Access Token API (https://api.dolby.com/media/oauth2/token) with the new API for API Tokens (https://api.dolby.io/v1/auth/token) in your Dolby.io applications. Next, you can make additional modifications to your Dolby.io Apps to change the default API Token expiration of 30 minutes to 12 hours. See the code examples below.

Code examples

The following examples show you how to create an API Token using your new App Key and App Secret credentials that you created during the Locate your App Key and App Secret procedure.

This example is modified to request an API Token that expires in 12 hours. The API Token expiration can be specified using the expires_in parameter.

import requests
import json
import os
APP_KEY = os.environ['APP_KEY']
APP_SECRET = os.environ['APP_SECRET']
payload = { 'grant_type': 'client_credentials', 'expires_in': 43200 }
response = requests.post('https://api.dolby.io/v1/auth/token', data=payload, auth=requests.auth.HTTPBasicAuth(APP_KEY,APP_SECRET))
body = json.loads(response.content)
access_token = body['access_token']
import fetch from 'node-fetch';
 
const auth = Buffer.from(`${process.env.APP_KEY}:${process.env.APP_SECRET}`).toString('base64');
const response = await fetch('https://api.dolby.io/v1/auth/token', {
    method: 'POST',
    body: new URLSearchParams({
        grant_type: 'client_credentials',
        expires_in: 43200
    }),
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': `Basic ${auth}`
    }
});
const json = await response.json();
const access_token = json.access_token;
AUTH=$(echo $APP_KEY:$APP_SECRET | tr -d '\n' | base64)
curl -X POST  https://api.dolby.io/v1/auth/token -H "Authorization: Basic $AUTH" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=client_credentials&expires_in=43200'

🚧

By default, the Authentication API (https://api.dolby.io/v1/auth/token) issues API Tokens that expire in 30 minutes. The deprecated Access Token API (https://api.dolby.com/media/oauth2/token) issued Access Tokens that expired in 12 hours.

Migration tips

The following list contains tips to help make your transition from using API Keys or Access Tokens to API Token authentication easier.

  • Make sure you are not storing or continuing to use API keys with API Token authentication.
  • Before starting to use the API Token authentication method, make sure all of your code is updated to point to the Dolby.io Authentication endpoint: https://api.dolby.io/v1/auth/token.
  • Update applications that are continuing to use API Keys to using API Tokens. This will prevent future issues when Dolby.io discontinues support for the API Key and Access Token authentication.