Table of content

Refresh token


Overview

Note:

It is only possible to refresh a token when using the password or authorization_code grant types. The client_credentials one isn’t providing this option.

An access token is always valid for a limited amount of time – indicated in seconds in the expires_in property of the JSON response.

Example of a JSON response with an access token and a refresh token:

{ 
"access_token": "<ACCESS_TOKEN>", 
"expires_in": 36000,   //  access token validity in seconds
"refresh_token": "<REFRESH_TOKEN>" 
}

The refresh token allows you to request a new access token once the last one expired without having to use user credentials again.


Implementation

To do so, you need to make a POST request to the token endpoint and include the following parameters:

  • grant_type: set to refresh_token to specify the grant type flow
  • client_id: your API key
  • client_secret: your API secret
  • refresh_token: the refresh token retrieved with your access token

Request example:

Platform API
Reporting API
POST /oauth/token HTTP/1.1
Host: api.dailymotion.com
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token
    &client_id=<API_KEY>
    &client_secret=<API_SECRET>
    &refresh_token=<REFRESH_TOKEN>
POST /oauth/token HTTP/1.1
Host: graphql.api.dailymotion.com
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token
    &client_id=<API_KEY>
    &client_secret=<API_SECRET>
    &refresh_token=<REFRESH_TOKEN>

In return, you will get the following JSON response:

{
    "access_token": "<ACCESS_TOKEN>",
    "expires_in": 36000,
    "refresh_token": "<REFRESH_TOKEN>"
}
Important:

We recommend using an access token for its whole validity before refreshing it. Refreshing tokens too often may trigger rate limitations.