0👍
In your setting.py
AUTHENTICATION_BACKENDS = (
# Google
'social_core.backends.google.GoogleOAuth2',
# Django
#'django.contrib.auth.backends.ModelBackend',
)
# Google Keys
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'KEY' # Client ID
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'SECRET_' # Client secret
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/'
context processors
'context_processors': [
...
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
],
urls.py
urlpatterns = [
...
url('social/', include('social.apps.django_app.urls', namespace='social')),
...
]
in your template add.
<p><a class="btn btn-lg btn-danger btn-block" href="{% url 'social:begin' 'google-oauth2' %}">Entrar con la cuenta de Google</a></p>
Source:stackexchange.com