I set up a custom rule to add user.app_metadata to the accessToken, which I retrieve when logging in.
I did not set any other configuration as I assume that rules work on every request when they are enabled.
I use the auth0-js client library and can successful login and retrieve a accessToken.
This is my rule:
function (user, context, callback) {
const namespace = "https://my_namespace/"; // my_namespace is a placeholder...
context.accessToken[namespace + "app_metadata"] = user.app_metadata;
callback(null, user, context);
}
Are you sure you are getting an access token and not an ID token? I believe you need to specify token in your response type if you want an access token.
Otherwise, your rule looks fine to me. This is my template rule for that use case:
As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!