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

时间:2021-05-05 07:28:11

标签: django django-rest-framework google-oauth python-social-auth

我在 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”的模块

0 个答案:

没有答案
相关问题