I am trying to get an access token for the Management API in a NuxtJS app in a component mounted method following the Auth0 docs as below, with the relevant client ID and secret auto generated by the docs (obscured here), but get a 401 error ‘not authorised’, can anybody help as to where I may be going wrong?
mounted() {
const getToken = {
method: ‘POST’,
url: ‘https://XXXXXXXXXXX.auth0.com/oauth/token’,
headers: {
‘content-type’: ‘application/x-www-form-urlencoded’
},
form: {
grant_type: ‘client_credentials’,
client_id: ‘XXXXXXXXXXXXXXXXXXX’,
client_secret: ‘XXXXXXXXXXXXXXXXXXXX’,
audience: ‘XXXXXXXXXXX.auth0.com/api/v2/’
}
};
this.$axios(getToken).then((res) => {
console.log(res)
}).catch(function (error) {
console.log(error);
});
}