Post Login Action Enterprise Database Group ID Access

Hi!

I’m attempting to access the groupIds set on a user in a Post-Login action, though I don’t see a way to access these groupIds. I can see the groups have been set on a particular user (see attached screenshot), but not sure how to get to them. These groups are being provided from an external OIDC connection.

Thanks for any help you can provide!

1 Like

Hi @tadamski,

Thanks for reaching out to the Auth0 Community!

First, let me preface that some of the functionality in Actions are still in the progress of being implemented.

In this case, it may be worth trying to access the user’s groups attribute by calling event.user.groups.

If this does not return the defined values, you could work around it by including the groups as part of the user’s user_metadata and retrieving the values that way (event.user.user_metadata.groups)

If not, there is the option of using Auth0 Rules to get the user’s groups by calling user.groups.

Please let me know how this goes for you.

Thank you.

Hi @rueben.tiow, thanks for the suggestions!

I did try accessing the groups via event.user.groups, but I doesn’t look like those are available yet, as you indicated. The action IDE indicates the groups aren’t available (see screenshot below), but if I manually add a groups array to the user context during the Action test, it works, but in real life testing, the groups aren’t there.

I will give the Auth0 Rule a try, thanks again!

As a final follow-up, I ended up using the event.user.user_metadata.groups within the Action code, but to make that work, I made a small Auth0 rule to populate the user_metadata.groups first. This allowed me to keep most of the claims logic in the Action.

// Auth0 rule - user-metadata-groups
function (user, context, callback) {
  if (!user.user_metadata) {
    user.user_metadata = {};
  }
  user.user_metadata.groups = user.groups;
  return callback(null, user, context);
}
1 Like

Hi @tadamski,

Thank you for your responses.

I’m glad that you managed to make the event.user.user_metadata.groups approach work!

Please don’t hesitate to reach out if you have any further questions.

Thanks!

I’m having the same problem.
@rueben.tiow Is there an estimate on when groups is accessible from Actions?

Testing with a users raw data that contains the ‘groups’ sections makes the data available, but when adding the action to a flow it’s no longer available for the same user.

Hi @emil.enemaerke,

I don’t have the exact date, but it will be sometime this year in 2022. We’re in the process of deprecating Rules, and we anticipate all of the features to be available in Actions after that happens.

Please let me know if you have any further questions.

Thank you.

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