INSTALLED_APPS += [
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.github',
]
SITE_ID = 1
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]
# Allauth settings
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_USERNAME_REQUIRED = False
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': ['profile', 'email'],
'AUTH_PARAMS': {'access_type': 'online'},
},
'github': {
'SCOPE': ['user', 'repo', 'read:org'],
}
}
LOGIN_REDIRECT_URL = '/dashboard/'
from django.urls import path, include
urlpatterns = [
path('accounts/', include('allauth.urls')),
]
django-allauth provides ready-made social auth (Google, Facebook, GitHub, etc.). I configure providers in settings with API keys. It handles OAuth flows, token management, and account linking. Users can login with multiple providers. I customize templates to match site design. For custom user models, allauth integrates seamlessly. It includes email verification and password reset. This saves weeks of development compared to implementing OAuth from scratch. I enable only needed providers to reduce dependencies.