Hello,
I’ve also got my app working yet I’m encountering a 400 response when trying to use the Management API to update a user’s metadata.
So first I’m grabbing the authToken using the below POST:
function retrieveAuthAPIToken() {
var options = {
method: 'POST',
url: 'https://harlow777.us.auth0.com/oauth/token',
headers: {'content-type': 'application/json'},
data: {
grant_type: 'client_credentials',
client_id: 'fiEPVos93440A4u7lROfpUZ3tXTGEP7W',
client_secret: '<secret>',
audience: 'https://harlow777.us.auth0.com/api/v2/'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
return response.data.access_token;
}).catch(function(error) {
console.error(error);
return null;
});
}
Then I attempt to update the logged in user’s metadata using this PATCH:
function addCardToUserMetadata(user, authToken) {
var options = {
method: 'PATCH',
url: 'https://harlow777.us.auth0.com/api/v2/users/' + user.sub,
headers: {authorization: 'Bearer ' + authToken,'content-type': 'application/json'},
data: {
user_metadata: {
creature_collection:'1000'
}
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function(error) {
console.error(error);
});
}
This PATCH works when I run it as a cURL command but in the code it receives a 400 response. Any ideas on why this would happen?