Auth0 Flutter user_metadata not returned


I’m trying to use the auth0_flutter pub package for my Flutter project. The UserProfile class that’s used with authentication does not have user_metadata - is there a way to include that? The same class has an address, but what would that reflect when there’s no specified field for a user’s address in the Auth0 User management console.

Is the solution to hit the API directly without the package? Or is it necessary to set up an Action to get the information?

Please let me know if more information is needed.

Hey @CityHernandez welcome to the community!

You’ll need to add a Post-Login Action to add metadata to the user’s ID token - This should work:

exports.onExecutePostLogin = async (event, api) => {
  const namespace = '';
  if (event.authorization) {
    api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
1 Like

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