Get Started

Learn how to sign-up for Dailymotion and generate an access token.

Overview

We have to first register in order to use the API to explore Dailymotion data API endpoints. We need to complete a few steps before we can start using Dailymotion Data API. Follow the steps below to register and generate the Dailymotion API key:

  1. Visit the Dailymotion website and click the "Sign up" button to register for an account at the top right corner.
  2. Fill out the sign-up form and click the "Sign up" button.
  3. A validation code is sent to your registered email. Enter that code and click the "Verify email" button. Completing the sign up process will log you in automatically.
  4. After the sign up process is complete, you can upgrade your user account to the partner account by visiting this link. Click the "Upgrade to Partner" button, then click the "Accept terms" button on the next page.
  5. The next step is to create a channel. The "Create a channel" page lists some fields, and some of them are required (with an asterisk). After entering the values in the fields, click the "Save" button at the end of the page.
  6. Congratulations! Your channel has been created. The next step is to generate API keys. Click the settings button on the top right corner of the page and then click "API Keys."
  7. On the "API Keys" page, when you click the "Create API Key" button, a side panel will appear. Give "Title," "Description," and "Callback URL" for the API key and click the "Create" button. The "Description" and the "Callback URL" fields are optional.
  8. The "API key" and "API secret" have been generated to test. Dailymotion considers the "API key" as the client_id and "API secret" as the client_secret for the authentication process.

The slides below visually explain the steps:

Retrieve the access token

The URL in the code block below is used to get the access token:

"https://api.dailymotion.com/oauth/token"

Since we aim to fetch public data only, the client_id and the client_secret are used to get the access token. The grant_type is client_credentials because we use application credentials, not the authenticated user’s credentials. To generate the access token, we need to copy the “API key” and “API secret” from the “API keys” page and use them in the code. Let's do this by following the steps below:

  • Click "Edit" in the widget below.
  • Provide the API key and API secret in the API_KEY and API_SECRET fields, respectively.
  • Click "Save" to save the keys.
  • Click "Run" to generate the access token.
import requests
from pprint import pprint
import json

url = "https://api.dailymotion.com/oauth/token"

values = {
    'host': "api.dailymotion.com",
    'content-type': "application/x-www-form-urlencoded",
    'client_id': "{{API_KEY}}",
    'client_secret': "{{API_SECRET}}",
    'grant_type': "client_credentials",
    'version': 2
}
headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.request("POST", url, headers=headers, data=values)

pprint(response.json())
Retrieving the access token

The response of the code widget above is in JSON format. We’ll copy the access_token and use it throughout the course. This token will be valid for 36000 seconds (10 hours). After that, we’ll have to rerun the above code to retrieve the new access token.

Test the access token

Now that we have copied the access token, let’s paste it into the code widget below and test if our code works:

Press + to interact
headers = {'Authorization': 'Bearer {{ACCESS_TOKEN}}'}
url='https://api.dailymotion.com/echo?message=Congratulations!+Setup+is+completed'
response = requests.get(url, headers=headers)
pprint(response.content)