Azure SSO Integration - Issue with accessing the email with the Auth0 flows or Actions



The login works with Auth0 SSO Integration perfectly without any issue if no Custom Rules are added.
But if the rule is added, i get " 1. Request to Webtask exceeded allowed execution time" error. I have attached the HAR File as well. Please take a look
Auth0andBlazor.har (3.5 MB)

Hi there @ashokd welcome back!

I imagine this is just due to the fact that you are missing a call to callback, something like the following should do the trick:

function(user, context, callback) {
	
var namespace = 'https://example.com/';
let userId = user.user_id.substring(6,user.user_id.length);

  context.accessToken[namespace + 'user_id'] = userId;
  context.accessToken[namespace + 'email'] = user.email;
  context.accessToken[namespace + 'name'] = user.name;
  
  callback(null, user, context);
}

Alternatively, if you like to migrate to an Action, something like the following will work:

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

const namespace = 'https://my-app.example.com';

let userId = event.user.user_id.substring(6, event.user.user_id.length);

 api.accessToken.setCustomClaim(`${namespace}/user_id`, userId);
 api.accessToken.setCustomClaim(`${namespace}/email`, event.user.email);
 api.accessToken.setCustomClaim(`${namespace}/name`, event.user.name);

}

Hope this helps!

It worked for the rules section, i can find my user email in the user.upn, but in the actions, i cant find the email. how can i access upn within the actions?

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

Hi team!

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