Auth0 how to send email as username

602 Views Asked by At

After I upgraded Auth0 from version 9 to version 11, I face a problem while authenticating.

I have a request URL: https://my-domain.auth0.com/co/authenticate, and all the parameters in my request look good, except username. It sends truncated email as username parameter, i.e. if I type '[email protected]', it only sends 'someone' as username.

export class AuthService {
idToken: string;
lock = new Auth0Lock(myConfig.clientID, myConfig.domain, {
      responseType: 'id_token token',
         .........
      params: {
--------------->>>>>>>>>> if I write here:
          username: '[email protected]',
--------------->>>>>>>>>> then it sends this email as username parameter, 
no matter what I type in the login form. 
IS THERE A WAY TO WRITE SOMETHING LIKE username: 'email' (this one is not working)
      }
  }
});

Is there a way to send the full email as username?

1

There are 1 best solutions below

0
On

We can use the the Auth0 Management API v2 to update the username using patch_users_by_id (make sure to include the connection name when sending a patch to update the username).

To elaborate, I believe it depends on the type of connection you have that will determine how the username gets set. Example, for database connections if Requires Username is enabled then users can set the option for username so that they can then login with either their username or email address. If you're using the database connection you might also want to check the username length in the Dashboard > Connections > Database > your-db-connection > Username length. What type of connection do you use? What's your use case that you want to set username to the email? Depending on what you're trying to achieve we can look into using a Rule to store data in the user_metadata.