I have read all discussion about this matter on StackOverFlow but all of them seem outdated.
Does anyone know how to run facebook authentication on localhost in Django by social-auth-app-django ? I have spent probably a day or so trying to solve it but nothing works.
AUTHENTICATION_BACKENDS = (
'social_core.backends.facebook.FacebookOAuth2',
"social_core.backends.vk.VKOAuth2",
"django.contrib.auth.backends.ModelBackend"
)
SOCIAL_AUTH_URL_NAMESPACE = 'social'
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.auth_allowed',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.social_auth.associate_by_email',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)
SOCIAL_AUTH_STRATEGY = 'social_django.strategy.DjangoStrategy' # new
SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage' # new
# facebook
#FACEBOOK_APP_ID = ' xxx'
#FACEBOOK_API_SECRET = ' xxx'
SOCIAL_AUTH_FACEBOOK_KEY = ' xxx' # new
SOCIAL_AUTH_FACEBOOK_SECRET = 'xxx ' # new
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
'fields': 'id,name,email',
}
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = ['username', 'first_name', 'email']
MIDDLEWARE = [
'debug_toolbar.middleware.DebugToolbarMiddleware', # new
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware', # new
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
You have to run localhost as a ssl server.
pip install django-sslserver
Add the application to your INSTALLED_APPS:
INSTALLED_APPS = (...
"sslserver",
...
)
And run:
python manage.py runsslserver