Rule to add user_metadata attributes to user object in Authentication API not showing up

Modified the Add persistent attributes to the user rule to add phone_number attribute under user_metadata object to user object but user object received in React app does not include phone_number attribute even though it shows in the console log when debugging rule.

Here is the rule code:

function addPersistenceAttribute(user, context, callback) {
  user.user_metadata = user.user_metadata || {};
  user.user_metadata.phone_number = user.user_metadata.phone_number || '12345678';
  context.idToken.phone_number = user.user_metadata.phone_number;

  auth0.users
    .updateUserMetadata(user.user_id, user.user_metadata)
    .then(function () {
	    console.log('user:', user, 'context', context);
      callback(null, user, context);
    })
    .catch(function (err) {
      callback(err);
    });
}

Hi @m.kuo5

What do you mean “user object”? Do you mean the ID token or something else?

John

Hi John,

Yeah the idToken or the user object through useAuth0 through the auth0-react package.

Can you capture the ID token and use JWT.io to verify the contents? What does it show?

John