Auth0 Home Blog Docs

Cannot set username for connection without requires_username



Hi, We’re in the process of migrating from version 1 to version 2 of the user management API but have run into a problem with usernames.

With version 1 of the API we are able to create users that have a username. With version 2 creating a user with a username or attempting to add a username to an existing user results in a Cannot set username for connection without requires_username error:

client.patch_user(id, { username: ‘a-guid’ })

=> {“statusCode”:400,“error”:“Bad Request”,“message”:“Cannot set username for connection without requires_username”,“errorCode”:“operation_not_supported”}

I assume the error message is referring to the Requires username option on the connection. Is there a way to enable usernames without requiring them?

The connection is used by multiple clients so I’m nervous about enabling the Requires username feature in case it has unwanted side effects for the other clients.

Thank you!


The username can only be set if the Requires username option is enabled for the connection. Can you describe your use case a bit more (e.g. Do you want users to use a username to log in, or only to display on your UI?).


Hi @prashant,

Thanks for the reply.

Yes we want to allow users to login using the username. We using Auth0 to control access to an API. Our API authenticates username+passwords by calling /oauth/ro with a client_id, username & password.

We were using version 1 of the API to create users
Auth0::Api::V1::Users#create_user and were passing the username in the request_params argument.

With version 2 of the API we’re calling Auth0::Api::V2::Users#create_user. With the V2 method when called with a username param we get an error unless Requires username is enabled.

Thanks, Trevor


Hi, @prashant,
I’ve encountered this same issue. We would like to separate the username and email so that users can log in using username instead of email. However, we need to do this for existing users.
Also, it sounds like this issue would prevent a user from changing their login ID (username), which seems broken to me.
Can you provide any insight? Assistance?