Thanks for the quick reply @tyf!
I call a wrapper around axios like so:
async function getManagementAPIAccessToken(): Promise<any> {
const url = `${process.env.AUTH0_DOMAIN}oauth/token`
const options = {
headers: {
'content-type': 'application/json'
}
}
const data = {
client_id: process.env.AUTH0_CLIENT_ID,
client_secret: process.env.AUTH0_CLIENT_SECRET,
audience: process.env.AUTH0_MANAGEMENT_API_AUDIENCE,
grant_type: process.env.AUTH0_GRANT_TYPE
}
const response = await HttpService.post(url, data, options)
return response
}
And the wrapper looks like this:
async function post(url: string, data: any, config?: any ): Promise<any> {
let result = {}
try {
const request = await axios.post(url, data, config)
result = request.data
}
catch(error) {
result["error"] = (error as any).response.data
}
return result
}
From my package.json:
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.6",
"@types/node": "^18.11.10",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"eslint": "^8.10.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},
"dependencies": {
"@types/mongoose": "^5.11.97",
"@types/ws": "^8.5.3",
"axios": "^1.2.0",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.17.1",
"express-oauth2-jwt-bearer": "^1.1.0",
"express-validator": "^6.14.0",
"fast-xml-parser": "^4.0.8",
"heartbeats": "^5.0.1",
"mongoose": "^6.7.5",
"nodemon": "^2.0.7",
"ws": "^8.7.0"
}
Thank your for your attention to this matter.