Rule to add user email to access token?

For the people who want to migrate their Auth0 Rules, due to the deprecation on Feb 25, 2022, here’s how the Auth0 Action version would look like:

exports.onExecutePostLogin = async (event, api) => {
  // This rule adds the authenticated user's email address to the access token.
  if (event.authorization) {
    const namespace = 'https://MY_DOMAIN_DOT_COM';
    api.accessToken.setCustomClaim(`${namespace}/claims/email`, event.user.email);
  }
};

Detailed migration guide can be found here:

1 Like