This multistep quickstart guide will walk you through setting up and managing authentication in your Node.js web apps using Auth0. Each step demonstrates how to implement a specific feature of Auth0 and is accompanied by a downloadable sample project showing the complete solution.
These tutorials and seed projects have been tested with the following:
- NodeJS 4.3 or superior
- Express 4.11
Create an Application
Create an Auth0 account (or login) and add an authentication client instance from the dashboard. Once you create your client, you will be provided with credentials (domain, client ID, and client secret) which should be stored somewhere safe (do not commit this information to your git repo!). After you login, the sample projects available for download will be pre-configured with your Default App credentials.
Configure Callback URLs
Callback URLs are the URLs that Auth0 invokes after the authentication process. Auth0 routes your application back to this URL and attaches some details to it including a token. Since callback URLs can be manipulated, you will need to add your application's URL in the app's
Allowed Callback URLs for security. This will enable Auth0 to recognize these URLs as valid. If omitted, authentication will not be successful for the app instance.
The sample projects which accompany each of these steps will have the following directory structure:
├── app.js ├── bin │ └── www ├── package.json ├── public │ └── stylesheets │ └── style.css ├── README.md ├── routes │ ├── index.js │ └── ... └── views ├── index.jade └── ...
All the project dependencies are managed by npm and listed in the
package.json file for each of the samples.
Run the following command to install the required packages.
Auth0's Lock widget and
auth0.js library are used throughout these quickstarts. These scripts can be obtained from the following CDN links:
Running the Sample Applications
After installing the dependencies for each of the samples, start the application:
With everything set, the app will be available at