omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

cant' Get linkedin extradata #940

Closed tanvirraj closed 7 years ago

tanvirraj commented 8 years ago

Trying so much hard to get linkedin extra data , when a user try to Sign up but cant' get email or full profile list

here is my setting.py

` SOCIAL_AUTH_LINKEDIN_SCOPE = ['r_fullprofile', 'r_emailaddress']

SOCIAL_AUTH_LINKEDIN_FIELD_SELECTORS = [ 'email-address', 'headline', 'industry']

SOCIAL_AUTH_LINKEDIN_EXTRA_DATA = [('id', 'id'), ('firstName', 'first_name'), ('lastName', 'last_name'), ('emailAddress', 'email_address'), ('headline', 'headline'), ('industry', 'industry')] `

and here is my view.py ` def save_profile(backend, user, response, request, _args, *_kwargs): if backend.name == 'facebook' or backend.name == 'linkedin-oauth2': try: user_profile = UserProfile.objects.get(user=user.id) print "printing try profiel...." print user_profile except: if backend.name == 'facebook': user_id = User.objects.get(pk=user.id) Candidate.assign_role_to_user(user_id) candidate = EmployeeResume(first_name=user.first_name, last_name=user.last_name, email=user.email, created_by=user ) candidate.save()

            profile = UserProfile(user=user_id, first_name=user.first_name, last_name=user.last_name,
                                  user_role="CANDIDATE")
            profile.first_name = user.first_name
            profile.save() 
            access_token = response["access_token"]
            uid = kwargs["uid"]
            # uid = 100009659355226
            print access_token
            print " printing uid ......"
            print uid
            if access_token:

                url = u'https://graph.facebook.com/{0}/' \
                u'friends?fields=id,name,picture,email' \
                u'&access_token={1}'.format(
                    uid,
                    response['access_token'],
                    )
                fb_request = urllib2.Request(url)
                friends = json.loads(urllib2.urlopen(fb_request).read()).get('data')
                print "start into friend loop"
                print "pirnt frind ..."
                print friends 
                for friend in friends:
                    print friend
                    # contact = Contacts(full_name=friend["name"],)

        elif backend.name == 'linkedin-oauth2':
            print "linkedin kwargs......"
            print kwargs
            user_id = User.objects.get(pk=user.id)
            Candidate.assign_role_to_user(user_id)
            candidate = EmployeeResume(first_name=user.first_name,
                                           last_name=user.last_name, email=user.email,
                                           created_by=user
                )
            candidate.save()

            profile = UserProfile(user=user_id, first_name=user.first_name, last_name=user.last_name,
                                  user_role="CANDIDATE")
            profile.first_name = user.first_name
            print "before profile save ..."
            profile.save()
            print "After profile save ..."

` User can sign UP but can't get his email adddress

omab commented 7 years ago

Your settings are for linkedin backend, but your code is expecting linkedin-oauth2, your settings should be named like SOCIAL_AUTH_LINKEDIN_OAUTH2_*.

Please format properly the snippets when submitting a ticket.