I want to update a single user from my api.
I have a function in Express:
const updateUserAuth0 = async (req, res, next) => {
var _token = await req.token.access_token;
var apiToken = "Bearer " + JSON.stringify(_token).replace(/['"]+/g, "");
var apiOptions = {
method: "PATCH",
url:
"https://myurl.eu.auth0.com/api/v2/users/{" +
new_user_id +
"}",
headers: {
authorization: apiToken,
"content-type": "application/json",
},
body: {
family_name: "Newfamily",
},
};
axios
.request(apiOptions)
.then(function (response) {
req.allUsers = response.data.user_id;
next();
})
.catch((err) => {
console.log("ERROR RESPONSE", err.response.status);
if (err.response.status === 409) {
res.sendStatus(409);
}
next(err);
});
};
I call this function and pass it an access token with scopes “read:users update:users create:users read:users_app_metadata update:users_app_metadata create:users_app_metadata update:roles read:organizations update:organizations create:organization_members read:organization_members”
On the Auth0 Management API dashboard page on Machine to Machine Applications tab I clicked the down arrow on the API and updated to add the permissions on the access token.
On the MyAPI dashboard page on Machine to Machine Applications tab I clicked the down arrow on the API and updated to add the permissions on the access token.
On the user I am accessing myApi with, I allow all these permissions for myApi and the Auth0 Mgmt API
I have clicked and allowed everything available! I have no idea why I can’t change the user properties with the request as outlined in the mgmt api v2 docs
All I get is 400 - sometimes 404 as I change between slightly different syntax - what am I doing wrong?