2017-03-22 4 views
0

Ich versuche, meine Django Website mit Github-Authentifizierung unter Verwendung von Python-Social-Auth BibliothekPython Social Auth Django Github OAuth

Konfiguration so weit zu integrieren:

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')), 

Aber wenn ich auf den Link klicken, zeigt es eine 404 Not Found Seite. Und wo stelle ich den geheimen Schlüssel und andere github-Konfiguration?

Antwort

0

Sie gehen in die Datei des Projekts.

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 = '' 
Verwandte Themen