Auth0 Home Blog Docs

Empty user_metadata

I am trying to write a rule that will return a user’s user_metadata to me in C# using the following code…

var claimsIdentity = User.Identity as ClaimsIdentity;

string accessToken = claimsIdentity?.FindFirst(c => c.Type == "access_token")?.Value;
string idToken = claimsIdentity?.FindFirst(c => c.Type == "id_token")?.Value;

AuthenticationApiClient client = new AuthenticationApiClient(new Uri(string.Format("https://{0}", ConfigurationManager.AppSettings["auth0:Domain"])));
var profile = await client.GetUserInfoAsync(accessToken);

I have been playing with rules to help with this, and every time I try to get the user_metadata property, it is null, even when my user has user_metadata. When just trying the following in a rule, I get no data…

function (user, context, callback) {
  user.user_metadata = user.user_metadata || {};
  context.idToken[''] = user.user_metadata;
  callback(null, user, context);

I am able to see the data if I set the properties in a rule, but not when attempting to just reading the data. This returns data to C#… = "Jane Doe";
user.user_metadata.given_name = "Jane";
user.user_metadata.family_name = "Doe";
 auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
    .then(function() {
        context.idToken[''] = user.user_metadata;
        callback(null, user, context);
    .catch(function (err) {

Thoughts as to why this is not working for me?