Converting rule to action, how to deal with user.upn?

Ready to post? :mag: First, try searching for your answer.
I am converting the following rule to action:

function (user, context, callback) {
  user.email = user.email || user.upn;
  callback(null, user, context);
}

I cannot figure out how to get the upn in an action.
It is really important because sometimes I have noticed that email is missing for some users and then I need to use upn instead.

Hi @daniel.ekbom

Welcome to the Auth0 Community!

One of the user had a similar problem and solved it with the usage of Management API with getUser({ id: user.user_id })

Thanks
Dawid

So the answer to this is to use the management api, yet Auth0 advocates against using the management API in actions. The following is from auth0’s migrate from rules to actions document.

https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions

In general, we do not recommend calling the Management API from a high-traffic, critical path like Rules or Actions. Requests to all Auth0 APIs are rate limited, including calls from extensibility points, and calling an API for all logins could easily result in failed logins at high-traffic times

Why isn’t the users upn available on the user object like it was in rules? Why wasn’t this listed in as a limitation in the actions limitations doc? Actions Limitations

Will making management api calls in actions go against our M2M token auth quota?

Upon further investigation it looks like upn is now available on event.user? I tested by logging the users upn in a test action and it seems to be available, the types just need to be updated in the action editor, so good news!

Confirmation that this value is available and safe to use would be appreciated. Thanks

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

Hi @kreiswig and @daniel.ekbom

We’ve updated our Knowledge Solutions with a chapter about Adding Claims with Action in a similar fashion to how Rules worked. You can find it here → Azure AD Integration not Providing the User Email

Thanks
Dawid