Token

Request for an access token by using client credentials.

The following will be provided by DCM:

  • CLIENT_ID

  • CLIENT_SECRET

  • AUDIENCE

  • DCM_AUTH_DOMAIN

  • X-API-KEY

Request

URL: <DCM_AUTH_DOMAIN>/oauth/token

Method: POST

Headers:

Parameter

Type

Mandatory

Default Value

Description

Content-Type

string

Yes

 

Indicates the media type of the resource. Use application/json.

X-API-KEY

string

Yes

 

Key used to authorise request.

Parameters:

Parameter

Type

Mandatory

Description

client_id

uuid

Yes

Application's Client ID.

client_secret

uuid

Yes

Application's Client secret.

audience

integer

Yes

The audience for the token, which is the API to be accessed.

Example:

cURL

Bash
curl --location '<DCM_AUTH_DOMAIN>/oauth/token' \
--header 'X-API-KEY: <X-API-KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "client_id": "<CLIENT_ID>",
    "client_secret": "<CLIENT_SECRET>",
    "audience": "<AUDIENCE>"
}'

Python

Python
import requests
import json

url = "<DCM_AUTH_DOMAIN>/oauth/token"

payload = json.dumps({
  "client_id": "<CLIENT_ID>",
  "client_secret": "<CLIENT_SECRET>",
  "audience": "<AUDIENCE>"
})
headers = {
  'X-API-KEY': '<X-API-KEY>',
  'Content-Type': 'application/json'
}

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

Response

Format: application/json

Name

Type

Description

access_token

String

Access token.

expires_in

String

Expiry in milliseconds.

scope

String

Scope of the token.

token_expiry

String

Expiry in date.

token_type

String

Type of token. Defaulted to “Bearer”.

Example:

JSON
HTTP/1.1 200 OK
Content-Type: application/json
{
    "access_token": "<access_token>",
    "expires_in": "86400",
    "scope": "<scope>",
    "token_expiry": "<yyyy/mm/dd hh:mm:ss>",
    "token_type": "Bearer"
}