Action Trigger on login does not add custom field email to acces token

I configured my action trigger - on login like that:

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

I deployed it and add it to the flow. In logs everything is fine. I successfully made a post registration action but login action actually doesn’t modify access token.
So to be confident that I test it correctly I’ ve added a similar rule:

function addEmailToAccessToken(user, context, callback) {
  context.accessToken['email'] =;
  return callback(null, user, context);

And it works great.
I think it’s some kind of a bug of an action trigger functionality.

Hi @dev30,

Thanks for reaching out to the Auth0 Community!

I understand that you’re having issues getting the Post-Login Action script to append custom claims to your access token.

After looking at your code snippet, it appears that you did not specify a namespace to append your custom claim. Read Create Namespaced Custom Claims for more details.

Given that, I recommend that you do something like the following in your Post Login Action script:

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

There is also a add user roles to tokens example use-case which you might find helpful.

Hoped this helps!

Please let me know if you have any further questions.

Thank you.

1 Like

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