My ultimate goal is to access a case-sensitive version of the username in my backend API. From what I’ve read, we should not include/send this with the access token from the client to the backend API, but instead we should call the /userinfo endpoint from the backend API (using the access token). The username is stored in all lowercase, so I read in another thread that we can store the original case sensitive username as part of the user_metadata. I have created the below rule to try to save the original case sensitive username into user_metadata.
function (user, context, callback) {
user.user_metadata = user.user_metadata || {};
user.user_metadata.username = user.username;
context.idToken['https://example.com/username'] = user.user_metadata.username;
auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
.then(function(){
callback(null, user, context);
})
.catch(function(err){
callback(err);
});
}
I have checked the “Requires Username” field in the dashboard so that the username field shows up on the signup screen. When I sign up a new user, and then later call the /userinfo endpoint (from my backend API), I get a property back that looks like this below, but the value is converted to all lowercase.
"https://example:com/username": "helloworld"
Please let me know how I can achieve what I am trying to do.
Thanks!