What I am trying to do?
I am trying to access the data from the social account. And for that I am following this site.
What is the problem?
I am getting the following error after successfully logged in to my facebook account:
Error: IndexError at /accounts/facebook/login/callback/
list index out of range
Looking it up on the internet I saw this post and tried to implement it but that gave a keyerror 'user'
.
My Code:
adaptar.py:
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
from allauth.socialaccount.models import SocialAccount
class CustomAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin):
account_uid = SocialAccount.objects.filter(user_id=request.user.id, provider='facebook')
print account_uid[0].extra_data['first_name']
settings.py:
SOCIALACCOUNT_ADAPTER = 'Authentication.adapter.CustomAdapter'