I am trying to integrate the social login into my project. during login Facebook, gives the error 'tuple' object has no attribute 'encode'.I have used django-allauth django-allauth
and I used the Heroku go deploy projects. to see the error click.
Inside the database data, entry from Facebook is happening.
any suggestions to rid of this problem.
Exception Type: AttributeError
Exception Value:
'tuple' object has no attribute 'encode'
django-allauth parameters from setting.py SITE_ID = 1
# Provider specific settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER =os.getenv('HOST_EMAIL', '[email protected]'),
EMAIL_HOST_PASSWORD = os.getenv('HOST_EMAIL_PASSWORD', 'PASSWORD'),
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Concact share Team <[email protected]>'
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS =1
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5
ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT = 86400 # 1 day. This does ot prevent admin login frombeing brut forced.
ACCOUNT_LOGOUT_REDIRECT_URL ='/accounts/login/' #or any other page
ACCOUNT_PRESERVE_USERNAME_CASING = False # reduces the delays in iexact lookups
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = True
ACCOUNT_UNIQUE_EMAIL=True
ACCOUNT_USERNAME_MIN_LENGTH = 5
ACCOUNT_USERNAME_REQUIRED =True
ACCOUNT_USERNAME_VALIDATORS = None
#Account Signup
ACCOUNT_FORMS = {'signup': 'socialmodule.forms.SignupForm',}
Social Account Settings
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'METHOD': 'oauth2',
'SCOPE': ['email', 'public_profile', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'email',
'name',
'first_name',
'last_name',
'verified',
'locale',
'timezone',
'link',
'gender',
'updated_time',
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': lambda request: 'en_US',
'VERIFIED_EMAIL': False,
'VERSION': 'v2.12',
},
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
}
}
authentication backends used.
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]
Third party app used in Installed app.
THIRD_PARTY_APPS = [
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'rest_framework',
]
If anyone ever faces the same issue, check your settings.py file. It might have trailing commas. This was the issue for me. similar problem.
EMAIL_HOST_USER =os.getenv('HOST_EMAIL', '[email protected]')
EMAIL_HOST_PASSWORD = os.getenv('HOST_EMAIL_PASSWORD', 'PASSWORD')
remove the training " , ".