Rules adds email to custom claims, but not working with actions

Here’s my rule -

function addEmailToAccessToken(user, context, callback) {
  // This rule adds the authenticated user's email address to the access token.

  var namespace = '';

  context.accessToken[namespace + 'email'] =;
  return callback(null, user, context);

Here’s my action:

exports.onExecutePostLogin = async (event, api) => {
  const namespace = ''

  api.accessToken.setCustomClaim(namespace + 'email',

The action doesn’t work, but the rule works fine.

What’s going on?

Hey @KLP ,

I tried to reproduce your issue, and did the following:

exports.onExecutePostLogin = async (event, api) => {
  const namespace = '';
    // Set a claim 

And I got the token with the custom claim and value:
"": "",

Can you please try in a similar way? Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.