Python Social Auth Django Github OAuth

Python Social Auth Django Github OAuth

我正在尝试使用 Python-Social-Auth 库

将我的 Django 网站与 Github 身份验证集成

目前的配置:

settings.py

INSTALLED_APPS += (
 ...
 "social_django",
 "social_core",

)

AUTHENTICATION_BACKENDS = [
    "account.auth_backends.UsernameAuthenticationBackend",
    "social_core.backends.github.GithubOAuth2",
]

TEMPLATES = [
    {
            ...
            'context_processors': [
                ...
                "social_django.context_processors.backends",
                "social_django.context_processors.login_redirect",
            ],
        },
    },
]

login.html

<a href="{% url "social:begin" "GithubOAuth2" %}">Github</a>

urls.py

url("^socialaccounts/", include('social_django.urls', namespace='socialaccounts')),

但是当我点击 link 时,它显示 404 未找到页面。我应该把密钥和其他 github 配置放在哪里?

它们进入项目的 settings.py 文件。

INSTALLED_APPS += (
 ...
 "social_django",
 "social_core",

)

AUTHENTICATION_BACKENDS = [
    "account.auth_backends.UsernameAuthenticationBackend",
    "social_core.backends.github.GithubOAuth2",
]

TEMPLATES = [
    {
            ...
            'context_processors': [
                ...
                "social_django.context_processors.backends",
                "social_django.context_processors.login_redirect",
            ],
        },
    },
]

SOCIAL_AUTH_GITHUB_KEY = ''
SOCIAL_AUTH_GITHUB_SECRET = ''