Auth0 Home Blog Docs

How to retrieve user_metadata

javascript
auth0-js

#1

I am using the Javascript Auth0.js package. I am using my own login screen because it was necessary for our usage. I managed to figure out how to add a first name and last name to the user_metadata on signup. I now want to know how to retrieve and edit the metadata. I have worked out how to retrieve the users profile using this page and this code: auth0.client.userInfo(data.accessToken, (err, profile) => {...}. The problem is this does not seem to return the metadata. How can I access the metadata? Also how can I edit it and any other profile info.

It seems like I should be using this: https://auth0.com/docs/libraries/auth0js/v8#user-management but I can’t figure out how to use it I keep getting 400 errors. I don’t know what the values of YOUR_PRIMARY_IDENTITY_TOKEN and userid should be that may be part of the problem


#2

The primary identity token in the scenario where you are mostly interested in managing user metadata will be the ID token you received as part of end-user authentication. When account linking is in the mix you may have in your possession more than one of these tokens because you’ll be linking two identities and as such the documentation uses the primary terminology. However, for this use case it would be the received ID token associated with the user for which you want to manage the user metadata.

In addition, the 400 requests suggests that there’s something wrong with how you’re doing the call, but without more information about the exact error it’s difficult to guess the reason. If you have more error information, usually the 400 will be included with additional information in the response payload, then update your question if you continue to experience problems.


#3