How to do it...

To connect Auth0 to your Django project, follow these steps:

  1. Add the social authentication app to INSTALLED_APPS in the settings file, like so:
# myproject/settings/_base.pyINSTALLED_APPS = [    # …    "social_django",]
  1. Now, add the Auth0 settings required by the social_django app, which will be similar to the following:
# myproject/settings/_base.pySOCIAL_AUTH_AUTH0_DOMAIN = get_secret("AUTH0_DOMAIN")SOCIAL_AUTH_AUTH0_KEY = get_secret("AUTH0_KEY")SOCIAL_AUTH_AUTH0_SECRET = get_secret("AUTH0_SECRET")SOCIAL_AUTH_AUTH0_SCOPE = ["openid", "profile", "email"]SOCIAL_AUTH_TRAILING_SLASH = False

Make sure that you define AUTH0_DOMAIN, AUTH0_KEY, and AUTH0_SECRET in your secrets or environment variables. The values for those variables ...

Get Django 3 Web Development Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.