How to include the username in the ID token

I need to include the username field from the user in the ID token. I believe I need to set up a rule for this. I found an example on line;-

function (user, context, callback) {
context.idToken[‘https://[my-tenant-domain]/username’] = user.username;
return callback(null, user, context);

But this seems to have no effect. Can this be done?


Solved this myself;- You have to use a valid http or https namespace which is NOT your tenant name or any other Auth0 address.

1 Like

Glad you have figured it out and thanks for sharing with the rest of community!