I am trying to drop in Auth0 and replace login and registration methods in an existing REST api on the server. The current system uses email and password.
To that end I'm implementing the login and register endpoints using Auth0 as the backing store. I created a user with email and password successfully using the management api via my Node.js server.
var request = require("request");
var options = { method: 'POST',
url: 'https://test.auth0.com/api/v2/users',
headers:
{
'content-type': 'application/json',
authorization: 'Bearer SomeToken' },
body:
{ connection: 'Username-Password-Authentication',
email: '[email protected]',
password: 'test',
user_metadata: { enable_promotions: true },
email_verified: false,
app_metadata: {} },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
I'm stuck trying to figure out how to now authenticate that same user. I couldn't find an authenticate method on the management api, so I tried it using the authentication api but it says that username is required - in my case I created a user via email and not username.
a) do I have to use the autentication API rather than the management api to authenticate with password and email?
b) do I use the email as the username?