Hi Team,
I receive an email inform the Rules and Hooks will be discontinued.
I use Rule to add user data on ID_TOKEN. How I can add custom information on ID_TOKEN?
Sample fo Rule:
function (user, context, callback) {
// This rule adds user_metadata to idToken.
context.idToken[‘user.metadata’] = {
“custom_data_1”: user.user_metadata.custom_data_1
};
return callback(null, user, context);
}
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:
Hello, everyone! To improve our extensibility offering, we will be deprecating Rules and Hooks as an option for both customers and partners in November 2024 and will be unifying all of our extensibility features under Actions.
We will start removing Hooks access from new tenants/new customers in the coming weeks.
What action do you need to take?
If you’re able to make the migration to Actions now, we highly recommend doing so. To help with the migration process, we have documentation on migra…
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
Thank you Rueben!
I will test with your sample and read more in references!
Best regards
1 Like
Hi @douglas.freitas ,
Of course, you’re welcome!
Regards,
Rueben
system
Closed
June 9, 2023, 6:11pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.