Retrieve an Auth Token

Overview

Retrieve an access token that you can use when you make a request to a protected endpoint.

URL

POST /authToken

Request

You should have received your clientID and clientSecret from MetaMetrics when MetaMetrics set up your account.

Parameter Format Description
clientID String The identifier you use to connect to MetaMetrics' API.
clientSecret String The shared secret associated with your clientId that is used to authenticate your account.

Response

Code Description Example
200 The call was successful.
{
  "accessToken": "aBcDeFgGHiJkLmNoP",
  "expiresIn": 86400
}
401 We weren't able to authenticate your credentials. The access token is incorrect or missing
{
  "message": "Authentication with credentials failed",
  "exceptionType": "NotAuthenticated",
  "additionalInfo": "Authentication with credentials failed"
}
403 You can't perform this action. doesn't have access to this feature.
{
  "message": "You do not have permission to perform this action.",
  "exceptionType": "PermissionDenied",
  "additionalInfo": "You don't have access to this resource."
}

Code Examples

This Python example is written for use with Python 3 and above.

import requests
client_id = "abcdefg" # replace with your provided client ID
client_secret = "hijklmnopqrstuvwxyz" # replace with your provided client secret
response = requests.post(
  "https://[apiendpoint]/authToken", # replace with the endpoint for the api you're working with
  json={"clientId": client_id, "clientSecret": client_secret}
)
access_token = response.json()['accessToken']  # use in Authorization header