Prerequisites
Get access tokens
To ask Auth0 for a v2 token, perform aPOST
operation to the https://{yourDomain}/oauth/token
endpoint, using the credentials of the Machine-to-Machine Application you created in the prerequisite step.
The payload should be in the following format:
`{yourClientSecret}`
with the in the Settings tab of your Application.
The request parameters are:
Request Parameter | Description |
---|---|
grant_type | Denotes which OAuth 2.0 flow you want to run. For machine to machine communication use the value client_credentials . |
client_id | This is the value of the Client ID field of the Machine-to-Machine Application you created. You can find it on the Settings tab of your Application. |
client_secret | This is the value of the Client Secret field of the Machine-to-Machine Application you created. You can find it at the Settings tab of your Application. |
audience | This is the value of the Identifier field of the Auth0 Management API . You can find it at the Settings tab of the API. |
Use the
update:client_grants
and create:client_grants
scopes with only high-privileged applications, as they allow the client to grant further permissions to itself.Use Auth0’s Node.js client library
As an alternative to making HTTP calls, you can use the node-auth0 library to automatically obtain tokens for the Management API.Use access tokens
To use this token, include it in theAuthorization
header of your request.
You can get the curl command for each endpoint from the Management API v2 Explorer. Go to the endpoint you want to call, and click the get curl command link at the Test this endpoint section.
Example: Python implementation
This python script gets a Management API v2 Access Token, uses it to call the Get all applications endpoint, and prints the response in the console. Before you run it make sure that the following variables hold valid values:AUDIENCE
: The Identifier of theAuth0 Management API
. You can find it at the Settings tab of the API.DOMAIN
: The Domain of the Machine-to-Machine Application you created.CLIENT_ID
: The of the Machine to Machine Application you created.CLIENT_SECRET
: The Client Secret of the Machine-to-Machine Application you created.