Hi,
I’m currently working on a website and want to assign a role to a user from code. (It’s my first project using Auth0)
The problem is that I always get the response: statusCode: 401 error: Unauthorized message: "Missing Authentication (and a bunch of other stuff that probably isn’t relevant), even tough I use the same api token that worked, when using the api explorer/tried getting a new one every time I use. (The cURL command that the api explorer gives me, also doesn’t work).
that is my code:
`var options = {
method: 'POST',
url: 'https://TENANT.eu.auth0.com/api/v2/roles/ROLE_ID/users',
header: {
'content-type': 'application/json',
authorization: 'Bearer ACCESS_TOKEN',
},
data: {
"users": [userID]
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});`
I also tried a bunch of variations of that or assigning permissions instead of roles and everything gave me 401.
Thanks in advance!