October 2, 2022

Django social auth

Устанавливаем пакет

pip install social-auth-app-django

Добавляем настройки в settings.py

# social-auth-app-django
AUTHENTICATION_BACKENDS = (
    'social_core.backends.github.GithubOAuth2',
    'social_core.backends.vk.VKOAuth2',
    'social_core.backends.facebook.FacebookOAuth2',
    'social_core.backends.open_id.OpenIdAuth',
    'social_core.backends.google.GoogleOpenId',
    'social_core.backends.google.GoogleOAuth2',
    'social_core.backends.google.GoogleOAuth',
    'social_core.backends.twitter.TwitterOAuth',
    'social_core.backends.yahoo.YahooOpenId',

    'django.contrib.auth.backends.ModelBackend',
)

Добавим urls.py:

urlpatterns = [    
path('', include('social_django.urls', namespace='social')),
]

SOCIAL_AUTH_GITHUB_KEY = ''
SOCIAL_AUTH_GITHUB_SECRET = ''

https://webdevblog.ru/django-autentifikaciya-s-facebook-instagram-i-linkedin/

https://django.fun/ru/articles/tutorials/oauth-authentication-django-social-auth/

https://github.com/python-social-auth/social-app-django