12.3.第三方登录

social_app_django

使用文档请参考:https://python-social-auth.readthedocs.io/en/latest/configuration/django.html

Installing

pip install social-auth-app-django

Register the application

Add the application to INSTALLED_APPS setting

INSTALLED_APPS = (
    ...
    'social_django',
    ...
)

Database

you need to sync the database to create needed models once you added social_django to your installed apps:

./manage.py migrate

Authentication backends

Add desired authentication backends to Django’s AUTHENTICATION_BACKENDS setting:

URLs entries

Add URLs entries:

Template Context Processors

There’s a context processor that will add backends and associations data to template context:

文档地址:https://python-social-auth.readthedocs.io/en/latest/configuration/settings.html

Keys and secrets

  • Set up needed OAuth keys (see OAuth section for details):

URLs options

重写返回体逻辑

向返回体中添加name cookie和token cookie

social_core.actions.py

Last updated

Was this helpful?