Skip to main content
https://badge.fury.io/py/dj-two-factor-social-auth.svg https://codecov.io/gh/PetrDlouhy/dj-two-factor-social-auth/branch/master/graph/badge.svg

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)

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)

Source distribution for dj-two-factor-social-auth 1.0.2
File Size Uploaded
dj_two_factor_social_auth-1.0.2.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-two-factor-social-auth 1.0.2
File Interpreter ABI Platform
dj_two_factor_social_auth-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / dj_two_factor_social_auth-1.0.2.tar.gz

Download URL dj_two_factor_social_auth-1.0.2.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
83a54a2ddbcc03eeecf63f2526fe6e6d70c4938d1809ce5e9808e1977eec6838
BLAKE2b-256 checksum
How to use checksums
9adfd030e367ad84c1ffa864acebdbacc2b2bf177d66093e82a5a9ed678bb97f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / dj_two_factor_social_auth-1.0.2-py3-none-any.whl

Download URL dj_two_factor_social_auth-1.0.2-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf6fd75bf333f9cb2f0b6612b9283c729a1290ed7b2034887a0ff639cb236337
BLAKE2b-256 checksum
How to use checksums
eea4aaff6bc016aec849e91389389ff3a37d023a242ab2c67ad092f8f4346e22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page