Cannot retrieve username through rule

Hi, I am using Universal login and need to access email and username.
I have Requires UserName selected in Connections > Database.

I have setup the following rule:

function addAttributes(user, context, callback) {
 	context.accessToken[""] = user.nickname;
  context.accessToken[""] =;
 	context.accessToken[""] =;
  callback(null, user, context);

And it works when I debug using “TRY THIS RULE”.

However, when I sign up as a new user it behaves inexplicably:
given values of and "jdoe" the user object I get from useAuth0 is thus:

 nickname: "jonnydoe", 
 name: "",
 email: "",

When I review the user created in the database it uses different labels altogether but the rawJSON shows me that the name I entered on sign up has been assigned to

"username": "jdoe"

By adding user.username to the rule I can get the username but it still doesn’t show in the user object that is returned from useAuth0 in the npm package.

It is extremely confusing. There seems to be a gap between Universal Login config and the spa library?

Hi @itinsley,

You should be able to use the same method you are using to get nickname to get the username in the token.

Did you look at this topic:

Here are a few questions:

  • Are you seeing the username in the token? e.g. "": "exampleUsername"
  • Which SDK are you using? How are you referencing the username in your code?

Let me know

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.