Ich versuche, meine Django-Website mit der Github-Authentifizierung mithilfe der Python-Social-Auth-Bibliothek zu integrieren
Konfiguration bisher:
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")),
Wenn ich jedoch auf den Link klicke, wird eine 404-Seite angezeigt. Und wo stelle ich den geheimen Schlüssel und andere Github-Konfigurationen ab?
Antworten:
0 für die Antwort № 1Sie gehen in die Projekte settings.py
Datei.
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 = ""