social-auth-app-django集成第三方登录

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

官网文档:http://python-social-auth.readthedocs.io/en/latest/

  • 安装
pip install social-auth-app-django
  • 生成数据库表
./manage.py migrate

  •  settings配置

D:\Python36\Lib\site-packages\social_core\backends\ 此目录下包含现在主流网站的第三方登陆,例如微博、微信等

AUTHENTICATION_BACKENDS = (
    'social_core.backends.weibo.WeiboOAuth2',
    'social_core.backends.qq.QQOAuth2',
    'social_core.backends.weixin.WeixinOAuth2',
    'users.views.CustomBackend',
    'django.contrib.auth.backends.ModelBackend',
)
TEMPLATES = [
    {
        ...
        'OPTIONS': {
            ...
            'context_processors': [
                ...
                'social_django.context_processors.backends',
                'social_django.context_processors.login_redirect',
                ...
            ]
        }
    }
]
  • urls配置
url('', include('social_django.urls', namespace='social'))

  

 

posted @ 2017-10-19 15:04  shhnwangjian  阅读(1415)  评论(0编辑  收藏  举报