Auth0 Home Blog Docs

Create User then Login returns 401



I am just playing around with adding Auth0 into an existing app. Since we are going through our own backend I was using the management API to create a user. Then I turn around and log them in using the authentication API oauth/token route but I get a 401 even though I just created the user. If I go to the connection try in the backend that user I just created can login there but the oauth/token route is still return 401. This is what my request is passing:
method: ‘POST’,
url: ${auth0Settings.url}/oauth/token,
headers: {
Accept: ‘application/json’
body: {
grant_type: ‘password’,
username: username,
password: password,
client_id: auth0Settings.authentication.clientId

Am I missing something?


To give more information this is the curl I use to create the user (removing token and password:

curl -X POST -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -H ‘Authorization: Bearer ******’ -d ‘{“connection”:“Username-Password-Authentication”,“email”:“”,“password”:"******",“user_metadata”:{“first_name”:“Skip”,“last_name”:“Tester Rotter”,“mobile”:“5035551212”,“password_updated_at”:“2018-07-06T00:08:07.132Z”},“app_metadata”:{“source_ref”:“mobileTicket”}}’

Here is the login curl I used:
curl -X POST -H ‘Accept: application/json’ -H ‘content-type: application/json’ -d ‘{“grant_type”:“password”,“username”:“”,“password”:"********",“client_id”:"*******"}’


Ok after trying 100’s things I came to using and setting the realm value to the name of the connection.