User Authentication
Last updated
Last updated
Let's configure the authentication service needed to authenticate users in your app. As mentioned in the previous steps, we are employing (sign up for a free account ). Next, setup an Auth0 client app and API so that Auth0 can interface with your app.
Go to the and click the button.
Give your app a name and select Single Page Web Applications.
In the Settings for your new Auth0 client app, add http://localhost:3000/callback
to the Allowed Callback URLs.
Create a new client
Create a new API
New API Dialog
You're now ready to implement Auth0 authentication in your app.
Navigate to your src
directory and create a utils
folder. In the utils
folder, create a file, AuthService.js and add this code to it.
In the code above, we invoked the auth0
library. And we have methods for storing the tokens returned from Auth0, decoding them and getting the expiry date.
Danger Note: Replace the
CLIENT_ID
andCLIENT_DOMAIN
with the values from your Auth0 dashboard.
Go to in your Auth0 dashboard and click on the Create API button. Enter a name for the API. Set the Identifier to your API endpoint URL. In this example, this is http://localhost:3001/api
. The Signing Algorithm should be RS256
.
Info Note: As we want the best security available, we are going to rely on the . This method consists of redirecting users to a login page hosted by Auth0 that is easily customizable right from the .