I used Rules for want to include user.email in the jwt payload. Rules code is below.
function (user, context, callback) {
// It's actually a product-specific URL
var namespace = 'https://example.com/claims/';
context.accessToken[namespace + 'email'] = user.email;
console.log(context.accessToken);
console.log(user.email);
return callback(null, user, context);
}
console.log() is for Real-time Webtask Logs.
When I tested this with “TRY THIS RULE” in individual Rules page, the debug console was outputting the values as expected. But when tried to “TRY ALL WITH…” in root Rules page and tried to login from the actual product, the value was not added.
I can get the accessToken itself, so I can get the email directly, but I want to get it at the same time if possible. Please help me out. Thanks!
Are you saying that when you login from your app the rule is not firing? That doesn’t make any sense.
Make sure you have the real time webtask logs on, log in from your app, and check the logs to see what is going on.
As this topic is related to Rules - Hooks - Actions, 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!