How to Get an Access Token for Testing

Overview

This article explains how to obtain an Access Token to test an API.

Applies To

  • Access Token
  • Testing
  • Management API

Solution

If the Management API Token is required for testing environments, follow the Get Management API Access Tokens for Testing.

To obtain an access token for any custom APIs use the M2M application with the Client Credentials flow to retrieve an access token for any of the custom APIs (including Management APIv2 in production environments) by sending a request in the below format:

curl --request POST \
  --url 'https://{yourDomain}/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data 'client_id={yourM2MClientId}' \
  --data 'client_secret={yourM2MClientSecret}' \
  --data 'audience={yourApiIdentifier}