How to update user app_metadata

  • Which SDK this is regarding: nextjs-auth0
  • SDK Version: 1.3.1
  • Platform Version: 12.22.0
  • Code Snippets/Error Messages/Supporting Details/Screenshots:

I’ve got the basic login working :+1:. But I can’t figure out how to update user_metadata and app_metadata, from the client js or nodejs. Do I have to install and setup node-auth0 as well for these api calls? I can see how to get my token, do I just have to make my own API calls using it? Seems strange that these functions wouldn’t be built into the library.

Hi @andrewscofield,

Yes, that is correct. With node-auth0 you can use the ManagementClient to make these calls:

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

var management = new ManagementClient({
  token: '{YOUR_API_V2_TOKEN}',
  domain: '{YOUR_ACCOUNT}.auth0.com'
});

var params = { id: USER_ID };
var metadata = {
  foo: 'bar'
};

management.updateAppMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

But this functionality is not built into the nextjs-auth0 library.

You can get more information about using the management API in client JS here: Get Management API Access Tokens for Single-Page Applications

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.