I understand, thank you. However, I’m still having a similar issue even when calling the PATCH update from the backend instead. The token I’m getting back is not valid. For example, when I get my token manually from the Auth Management API’s API Explorer, and simply paste that into my code below, it works. But when I generate the token using the following, it gives me an authorization error.
I’ve tried using the axios version of the token request using headers: {‘content-type’: ‘application/x-www-form-urlencoded’}, it also says there is an authentication error.
const updateAuthUser = (user) => {
var request = require(“request”);var options = {
method: ‘POST’,
url: ‘https://chequemate.us.auth0.com/oauth/token’,
headers: { ‘content-type’: ‘application/json’ },
body:{"client_id":"${process.env.AUTH0_MGMT_API_CLIENT_ID}","client_secret":"${process.env.AUTH0_MGMT_API_CLIENT_SECRET}","audience":"${process.env.AUTH0_MGMT_API_AUDIENCE","grant_type":"client_credentials"}
};request(options, function (err, res, body) {
if (err) throw new Error(err);const token = body.access_token var options = { method: 'PATCH', url: `https://chequemate.us.auth0.com/api/v2/users/${user.auth0_id}`, headers: {'content-type': 'application/json', authorization: `Bearer ${token}`, 'cache-control': 'no-cache'}, body: `{"name":"${user.name}","picture":"${user.picture}"}` }; request(options, function (err, res, body) { if (err) throw new Error(err); return body })
})
}
(apologies, but the code markdown doesn’t seem to be working here)