Not Getting app_metadata Claims (OIDC Client)


I’m using the new Auth0.oidcClient with my .NET app. I’m successfully authenticating against my API and everything is working as far as the authentication, however I’m not receiving any of my custom claims from my app_metadata. For example, I have in my app_metadata a property called “app_metaDataproperty” and it’s not returned as a claim.

        private Auth0Client auth0 = new Auth0Client(ConfigurationManager.AppSettings"auth0:Domain"],
                                                    "openid profile app_metaDataproperty", 

            //Attempt to login
            var LoginResult = await auth0.LoginAsync(ExtraParms);
            //Next, attempt to get the to the protected resource on the web API
            if (LoginResult.IsError == false)
                var client = new RestClient("http://localhost:5896/api/ping/claims");
                var request = new RestRequest(Method.GET);
                request.AddHeader("authorization", string.Format("Bearer {0}", LoginResult.AccessToken));

                IRestResponse response = client.Execute(request);

If I make a call out to the /userinfo endpoint, it too doesn’t return my app_metadata.

Is there any way to get the app_metadata into my claims if I’m using the OIDC client?


OIDC-Conformant Clients require that custom claims are namespaced. You can add custom claims through the use of Rules like so:

function (user, context, callback) {
  const namespace = '';
  context.idToken[namespace + 'favorite_color'] = user.favorite_color;
  context.idToken[namespace + 'preferred_contact'] = user.user_metadata.preferred_contact;
  callback(null, user, context);

To update the contents of the access_token, simply replace context.idToken with context.accessToken.

The following resources should provide some additional clarity:

1 Like

This document seems to resolve my issue by adding a custom rule: