http://localhost:3000/callback
.http://localhost:3000
.requirements.txt
file in your project directory, and include the following:.env
file in your project directory. This file will hold your client keys and other
configuration details.webappexample/settings.py
file to review the .env
values.At the top of the file, add the os
and dotenv
imports.Next, beneath the BASE_DIR
definition, add the TEMPLATE_DIR
variable.Next, find the TEMPLATES
variable and update the DIRS
value to add our
TEMPLATE_DIR
string. This determines the path of the template files, which you will create in a
future step. Keep any other content of this array the same.At the end of this file, add the code to load the Auth0 config.webappexample/views.py
file in your IDE.Import all the libraries your application needs.Now you can configure Authlib to handle your application’s authentication with Auth0.Learn more about the configuration options available for Authlib’s OAuth register()
method from their documentation.login
- When visitors to your app visit the /login
route, they will reach Auth0 to
begin the authentication flow.callback
- After your users finish logging in with Auth0, they will return to your application
at the /callback
route. This route saves the session for the user and bypasses the need for them
to login again when they return.logout
- The /logout
route signs users out from your application. This route clears
the user session in your app and redirects to the Auth0 logout endpoint to ensure the session is no longer
saved. Then, the application redirects the user to your home route.index
- The home route will render an authenticated user’s details or allow visitors to sign in.webappexample/urls.py
file with the code on the right to connect to
these new routes.This will route the /login
, /callback
, /logout
and /
routes
to the correct handlers.webappexample
folder named templates
, and create
a index.html
file.The index.html
file will contain template code to display the user’s info if logged in or present
them with a login button if logged out.