Get Access Tokens for Production
To make scheduled frequent calls for a production environment, you have to build a process at your backend that will provide you with a token automatically (and thus simulate a non-expiring token).
Get Access Tokens
To ask Auth0 for a Management API v2 token, perform a
POST operation to the
https://YOUR_DOMAIN/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:
The request parameters are:
|grant_type||Denotes which OAuth 2.0 flow you want to run. For machine to machine communication use the value
|client_id||This is the value of the Client ID field of the Machine-to-Machine Application you created. You can find it at 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
The response will contain a signed JWT, when it expires, the scopes granted, and the token type.
From the above we can see that our Access Token is a Bearer Access Token, it will expire in 24 hours (86400 seconds), and it has been authorized to read and create applications.
Use Auth0's Node.js Client Library
Use Access Tokens
To use this token, include it in the
Authorization header of your request.
For example, in order to Get all applications use the following:
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 the
Auth0 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 Client ID of the Machine to Machine Application you created.
CLIENT_SECRET: The Client Secret of the Machine-to-Machine Application you created.