Add data on Access Token - avoid Rules and Hooks

Hi @douglas.freitas,

Welcome to the Auth0 Community!

Yes, that is correct! We recently made an announcement that Rules and Hooks is reaching the end of life:

Now, in this situation, what you will need to do is convert your existing Rule to a Post Login Action.

For your convenience, I have converted your Rule into a Post Action code snippet below:

exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://myapp.example.com';
  if (event.authorization) {
    // Set claims
    api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata.custom_data_1);
  }
};

To assist you further, I’ve also gathered some helpful resources that you can refer to:

Please let me know if there is anything else I can do to help!

Thanks,
Rueben

1 Like