I'm trying to add google authentication to my project
I installed it:
pip install python-social-auth
and added it in settings.py:
SOCIAL_AUTH_USER_MODEL = 'accounts.CustomUser'##
SOUTH_MIGRATION_MODULES = {
'default': 'social.apps.django_app.default.south_migrations'
}
AUTHENTICATION_BACKENDS = (
'myproject.middleware.AuthenticationCMSBackend',##
'social.backends.google.GoogleOpenId',
'social.backends.google.GoogleOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
LOGIN_REDIRECT_URL = '/'
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '507847...m.apps.googleusercontent.com'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'SEt-6...0j3'"""
TEMPLATE_CONTEXT_PROCESSORS = (
...
'django.core.context_processors.request',
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
)
As for the SOCIAL_AUTH_GOOGLE_OAUTH2_KEY and secert, I went to https://console.developers.google.com/apis/credentials and created them using localhost url (for testing for now)
I call it in template like this:
<a href="{% url 'social:begin' 'google-oauth2' %}"> login </a>
But I get this error:
Backend not found
What am i doing wrong?
next step, I want to make sure only users I validate can authenticate not anyone with google account, how to do so?