Django:如何使用自定义社交身份验证后端?

问题描述

我在 django social-auth 中覆盖了 GoogleOAuth2 类。 目前,新类在 views.py 中。

但我找不到如何将其添加到 settings.py 中的 AUTHENTICATION_BACKENDS

我试过这样:

AUTHENTICATION_BACKENDS = (
    '_auth.backends.YouTubeOAuth2',<---------- new backend
    'social_core.backends.google.GoogleOAuth2','social_core.backends.twitter.TwitterOAuth','social_core.backends.facebook.FacebookOAuth2','django.contrib.auth.backends.ModelBackend',)

并调整了模板:

window.open('{% url 'social:begin' 'youtube' %}','_blank','location=yes,height=570,width=520,scrollbars=yes,status=yes');

在 Google 身份验证过程结束时出现错误

ModuleNotFoundError at /apI/Oauth/complete/google-oauth2/ 没有名为“_auth”的模块

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)