App connecting django-two-factor-auth and social-app-django. If user authenticates through social auth, he will be enforced to go through 2FA (if he has 2FA enabled).
Documentation
The full documentation is at https://dj-two-factor-social-auth.readthedocs.io.
Quickstart
We expect, that you have already installed and configured django-two-factor-auth and social-app-django according to their documentation.
Install Django two factor auth for Django social auth:
pip install dj-two-factor-social-auth
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
"two_factor",
"social_django",
"social_2fa",
...
)
Add Django two factor auth for Django social auth’s URL patterns:
from django.urls import path
urlpatterns = [
...
path("", include("social_2fa.urls")),
...
]
Add social_2fa to your social pipeline in settings.py:
SOCIAL_AUTH_PIPELINE = (
...
"social_2fa.social_pipeline.two_factor_auth",
)
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Development commands
pip install -r requirements_dev.txt invoke -l
History
1.0.2 (2026-08-27)
Fix: take the session from the strategy instead of the pipeline’s request keyword argument, which social-auth-core 5.x overwrites with the request data when it resumes a partial pipeline (breaking the OTP round trip)
1.0.1 (2025-05-19)
Fix: session transfer of data
1.0.0 (2025-05-15)
Use session to transfer data (safer, more reliable)
Update support up to Django 5.2, Python 3.13 versions
Drop support for Python 3.8, Django 4.0 and below
0.1.2 (2023-03-09)
Try to rename package to be compatible with poetry (https://github.com/python-poetry/poetry/issues/6996)
0.1.1 (2023-03-08)
Update testing and setup.py to support newest Django, Python and django-two-factor-auth
0.1.0 (2022-03-21)
First release on PyPI.
Release files for dj-two-factor-social-auth 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dj_two_factor_social_auth-1.0.2.tar.gz | 20.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_two_factor_social_auth-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.4 kB