Lab 2: Calling an API
This lab covers the process for adding sign-in to a basic Node.js application and calling an API. This lab is the same exercise we provide for new employees in a technical role here at Auth0.
Read the introduction on the main Identity Labs page
Watch the Calling an API video
Read Using Express Middleware (optional)
Read Beginner's Guide to Using npm (optional)
What You'll Need
An Auth0 account - Sign up for a free Auth0 account. We recommend starting with a new, empty tenant that can be deleted when you have completed the exercises. If you're using an existing test or dev tenant, make sure that all Rules are turned off and MFA is turned off.
An Auth0 database user - Use a new username/email and password user in a test database connection instead of a social, enterprise, or passwordless login. While social logins might work, using development keys can cause the labs to run differently. Choose a simple password that's easy to type as you will be logging in and out multiple times. You can use the same user across all of the labs.
A web browser - This lab was built and tested using Google Chrome; Safari, Firefox, and Edge should all work fine as well. Disable any active ad blockers used for the domain of your local site, as well as for the Auth0 domain from your tenant.
The Identity Labs Git repo - All the code you need to start, as well as the completed exercise for guidance, is located in the GitHub repository. You need to clone that repo just once for all four labs. Use the correct folder relative to the lab you are working on. All file references in this lab are relative to
/begin unless otherwise indicated. An
/end folder is included as well to help with troubleshooting and compare your work with a working sample.
For macOS users - If you are new to macOS, check these quick tips for developers new to Mac. Make sure you allow the display of hidden files and become familiar with running basic commands in the terminal.
For Windows users - We recommend that you use the Windows PowerShell terminal (instead of the Windows command line) so that the terminal commands provided in the lab instructions work as they are. This is because the syntax of the commands used in the labs is the same for the Mac and PowerShell terminals.