Rule Not Updating my app_metadata but in debug it works

I have a rule in place that calls an external public api and returns data if the email exists. based on that data i set :

user.app_metadata.roles = userData;
user.app_metadata.companyId = userCompany;

when i debug it or i test it. It works and i see my data update. Now if I test it using the google auth, it does not work at at all. When i go to the user section in auth0 is does not show my updated app_metadata… Any ideas?


Hi @oflores2313

Install the real-time webtask logs extension and use console.log to view what is happening in the non-debug case.


I did and my profile is set correctly there when i console log it.

This is my code. Am i doing something wrong here:

function setRolesToUser(user, context, callback) {
  // setting my meta data
  user.app_metadata = user.app_metadata || {};
  user.app_metadata.roles = user.app_metadata.roles || '';
  user.app_metadata.companyId = user.app_metadata.companyId || '';

  console.log('OSCAR USER PROFILE', user);
  var axios = require("axios").default;
  var options = {
  	method: 'GET',
    url: `${}`,
    headers: {'content-type':'application/json'}
  .then( res => {
  	let userData;
    let userCompany;
    // checking if theres any returned data
    if( === 0){
      userData = '';
      userCompany = '';
    }else {
      // if data is returned from the API, then set the role and the companyId
      userData =[0].role.role_name;
      userCompany =[0].company_id;
    user.app_metadata.roles = userData;
    user.app_metadata.companyId = userCompany;
    if(user.app_metadata.roles) {
    	user.roles = user.app_metadata.roles;
    if(user.app_metadata.companyId) {
    	user.companyId = user.app_metadata.companyId;
    console.log('HELP!!!!!!!', user);
    callback(null, user, context);
  }).catch(err => {

You are missing the code to update the metadata in the profile:

.updateUserMetadata(user.user_id, user.user_metadata)
.then(function () {
  callback(null, user, context);
.catch(function (err) {


1 Like

Thanks for helping on this one John!

Thank you John!!!

1 Like

We are here for you!

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