Rules are working in the debug console, but they don't work when you use them

I used Rules for want to include in the jwt payload. Rules code is below.

function (user, context, callback) {
  // It's actually a product-specific URL
  var namespace = '';

  context.accessToken[namespace + '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!

Hi @u1f419,

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.


1 Like

Why is it? I thought Rules was supposed to be triggered during the authentication process, login, etc., but when is it actually triggered?

The actual code uses auth0-react, which is retrieved by getAccessTokenSilently after loginWithRedirect.

Rules are scripts that are run upon successful login

I understand. If so, how can I include the email in the accessToken and get it?

Hi @u1f419,

What do the realtime webtask logs show? Put some debug statements in, run it, and then put both the rule and the log output here.