getUser Method Not Returning All User Information

We are using a custom database connection for user authentication with Auth0. In our custom database we have several fields for each user that we want to be able to include in the access tokens that are generated when the users are authenticated. For example, one of these custom fields is the environment that the user is in (‘env’).

    "email": "",
    "nickname": "user",
    "env": "environment",

The first issue we ran into was that the access tokens were not including all the information we wanted. By setting the scope to ‘openid profile email’, the getUserInfo would not return the ‘env’ property. We tried adding ‘env’ to the scope but this did not work.

After browsing the Community topics I found a topic on custom claims which we were able to use to expose the ‘env’ property in the tokens by adding using a custom claim. The limitation to this, however, is that we are forced to use a namespace, which makes it more difficult to later store and access that property with a JavaScript object.

This is how we have to access the environment with custom claims:

    const userEnv = idToken[''];

It would be nice to be able to access that information more easily:

    const userEnv = idToken.env;

It would be much easier if we could specify a claim called ‘env’, which we could then use to access the environment of the user. Is this possible using custom claims? What about using the scope?

We feel like there has to be an easier way to expose these user profile attributes through the tokens than using a custom claim with a long clunky namespace.