Auth0's Management API v2 to update user profile

Hi @randall2,

Welcome to the Auth0 Community!

I understand you’ve been unsuccessful in updating a user when using the ManagementClient.

After looking through your code, I don’t immediately see an issue that stands out to rationalize why you were unable to update a user.

Because of this, could you please clarify if updating the user with the Management API Patch users by ID with your user-data.json file work successfully?

I have gone ahead and tested this out myself and was able to update the user without any problems, following the https://auth0.github.io/node-auth0/module-management.ManagementClient.html#updateUser as a reference. See below for my tested code.

  const ManagementClient = require('auth0').ManagementClient;

  const management = new ManagementClient({
      domain: event.secrets.domain,
      clientId: event.secrets.client_id,
      clientSecret: event.secrets.client_secret,
  });

  const params =  { id : event.user.user_id};
  const data = { "user_metadata":{"favorite_color": "blue"}};

  try {
    const res = await management.updateUser(params, data)
  } catch (e) {
    console.log(e)
    // Handle error
  }

Given that, I have a hunch that the issue may be related to your JSON data passed in the request.

Looking forward to your reply.

Thanks.

1 Like