Auth0 badgeAuth0 University

Getting Started with the lock

Getting Started with the lock

  1. Course Catalog
  2. Getting Started with the lock
  3. Getting Started with Auth0 Lock

Getting Started with Auth0 Lock

The demo is an Express application with a login and logout route, and some Javascript on the front-end. We can login using either Twitter or username/password, and logout.

Let's start with our assumptions for this exercise: you have a server with the following routes:

  • /users/authenticate, which Lock can call that will register a user as logged in
  • /users/logout, which Lock can call that will end a user's session and log them out

If you need help with these, we have quickstart guides in our docs, including the Express quickstart that I used to set this tutorial up.

We also have some elements in our Jade page layout:

  • .js-login, which corresponds to our 'Login' button
  • .js-logout, which corresponds to our 'Logout' button

Finally, we have imported the following libraries into our client-side environment:

That all being said, let's write our code to construct an instance of Lock that we can use. You'll need your ClientID and Auth0 domain, which you can find in the dashboard under 'Apps/APIs', and clicking your App's name.

var lock = new Auth0Lock('YOUR_CLIENT_ID', 'YOUR_DOMAIN.auth0.com');