# How do a signIn with Auth0 npm package?

**URL:** <https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132>\
**Category:** Get Help\
**Tags:** nodejs, signin, auth0\
**Created:** [January 4, 2018, 7:02pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132 "2018-01-04T19:02:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.banjo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@peter.banjo](https://community.auth0.com/u/peter.banjo)\
**Post date:** [January 4, 2018, 7:02pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/1 "2018-01-04T19:02:08Z")

</div>

We are looking to adopt Auth0 for a single sign-on for multiple apps but we have some existing users in our database. On the server-side we would like to attempt to login to our database with the user’s email and password and if unsuccessful attempt a login to Auth0.

I found the [auth0 npm package](https://www.npmjs.com/package/auth0) and the AuthenticationClient class but I’m not able to use it successfully based on the [documented example](http://auth0.github.io/node-auth0/module-auth.OAuthAuthenticator.html#signIn) - all my attempts fail with `SignIn failed: Invalid email or password`. My code is below -

```
const AuthenticationClient = require('auth0').AuthenticationClient;
...
const auth0 = new AuthenticationClient({
  domain: 'xxxxxxxxxx.auth0.com'
});
const data = {
  username: email,
  password: password
 };
try {
  const { error, response, user } = await auth0.oauth.signIn(data);
  return user;
} catch(e) {
   console.log(e)
}

```

I have also tried using multiple connections on the App client in Auth0 where the database connection is connected to a remotely, hosted DB and another connection to a SAML Identity Provider hosted in Auth0. But Auth0 does not support a round robin login when there are multiple connections. Is this true?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 4, 2018, 9:03pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/2 "2018-01-04T21:03:59Z")

</div>

Focusing on the first paragraph of your question what you describe is very similar to what’s given by a custom database connection with import mode enabled. This setup would allow to transparently migrate your existing users to the Auth0 user store. If on the other end you want to keep using your own store to keep the current and future user credentials then you would use a custom database connection without import mode. The important point is that there would only be a single database connection.

For reference information on both possibilities see:

- [Configure Automatic Migration from Your Database](https://auth0.com/docs/users/migrations/automatic) (with migration of credentials)
- [Custom Database Connections](https://auth0.com/docs/connections/database/custom-db) (without migration of credentials)

With regards to the issue with the SDK the method in question makes use of a [deprecated](https://auth0.com/docs/api/authentication#database-ad-ldap-active-) endpoint so I would not even recommend trying to make use of it. As to what you should use instead that mostly depends on the characteristics of the client applications so there’s insufficient information to answer that.

---

<div class="post-metadata">

**Author:** ![peter.banjo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@peter.banjo](https://community.auth0.com/u/peter.banjo)\
**Post date:** [January 4, 2018, 9:53pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/3 "2018-01-04T21:53:12Z")

</div>

Thank you @jmangelo. What I wanted was to see if we could keep our sign-in page by using Auth0 programmatically on the server-side - it looks like that’s not the case.

---

<div class="post-metadata">

**Author:** ![peter.banjo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@peter.banjo](https://community.auth0.com/u/peter.banjo)\
**Post date:** [January 4, 2018, 9:53pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/4 "2018-01-04T21:53:12Z")

</div>

Thank you @jmangelo. What I wanted was to see if we could keep our sign-in page by using Auth0 programmatically on the server-side - it looks like that’s not the case.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 4, 2018, 10:21pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/5 "2018-01-04T22:21:52Z")

</div>

It’s possible, you should use a non-deprecated endpoint (see [https://auth0.com/docs/api/authentication#resource-owner-password](https://auth0.com/docs/api/authentication#resource-owner-password)). You could use that endpoint to target the custom database connection that would then if needed call into the existing store.

---

<div class="post-metadata">

**Author:** ![peter.banjo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@peter.banjo](https://community.auth0.com/u/peter.banjo)\
**Post date:** [January 4, 2018, 11:58pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/6 "2018-01-04T23:58:14Z")

</div>

i tried and it doesn’t work - still getting invalid username and password but i’m able to sign in using the hosted page

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 9, 2018, 10:54pm UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/7 "2018-01-09T22:54:58Z")

</div>

Using the endpoint above be sure to use the `realm` parameter (requires adjusting the grant type also) to specify the exact database connection associated with the user; otherwise the endpoint will use the default connection configured at the tenant level which might not be correct.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 25, 2019, 9:29am UTC](https://community.auth0.com/t/how-do-a-signin-with-auth0-npm-package/9132/8 "2019-07-25T09:29:50Z")

</div>


