Hi, I found a few posts on this topic already, but I can’t seem to get this to work.  I have a custom rule to add user.email to the access token instead of fetching this information from userinfo.  The rule looks like this:
function (user, context, callback) {
    context.accessToken["https://MY_DOMAIN_DOT_COM/claims/email"] = user.email;
    return callback(null, user, context);
}
 
Yet still, I see nothing in the access token.  Any ideas?
             
            
               
               
               
            
            
           
          
            
            
              Hi,
This works in my tenant, I had to change the custom claim to single quotes.
function (user, context, callback) {
	context.accessToken['https://MY_DOMAIN_DOT_COM/claims/email'] = user.email;
return callback(null, user, context);
}
 
Including a link to our rules debugging doc in case it is helpful.
             
            
               
               
              2 Likes 
            
            
           
          
            
            
              Thanks for sharing that solution Marcus!
             
            
               
               
               
            
            
           
          
            
            
              
Thanks for update and quick reply, i found lots of information here, Really appreciate for help.
             
            
               
               
              1 Like 
            
            
           
          
            
            
              Perfect! Glad to hear that!
             
            
               
               
               
            
            
           
          
            
            
              Deleting previous message due to SPAM reasons.
             
            
               
               
               
            
            
           
          
            
              
                nikolay  
                
               
              
                  
                    September 1, 2021, 10:55am
                   
                   
              10 
               
             
            
              For the people who want to migrate their Auth0 Rules, due to the deprecation on Feb 25, 2022 , here’s how the Auth0 Action version would look like:
exports.onExecutePostLogin = async (event, api) => {
  // This rule adds the authenticated user's email address to the access token.
  if (event.authorization) {
    const namespace = 'https://MY_DOMAIN_DOT_COM';
    api.accessToken.setCustomClaim(`${namespace}/claims/email`, event.user.email);
  }
};
 
Detailed migration guide can be found here:
  
  
    Due to the future deprecation of Auth0 Rules, users are required to migrate their custom Rules to the latest Auth0 Actions. 
This post will guide you through this migration process. 
 Auth0 Rule to migrate
Name: Add user information to access token 
Script: 
function (user, context, callback) {
  // This rule adds the authenticated user's email address to the access token.
  var namespace = 'https://mydomain.com/';
  context.accessToken[namespace + 'email'] = user.email;
  context.accessToken[…
   
 
             
            
               
               
              1 Like 
            
            
           
          
            
            
              Thanks for sharing it with the rest of community!
             
            
               
               
              1 Like 
            
            
           
          
            
              
                system  
                
                  Closed 
               
              
                  
                    September 16, 2021, 11:43am
                   
                   
              12 
               
             
            
              This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.