def authenticate(self, linkedin_access_token, user=None):
        linkedin = LinkedIn(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET)
        # get their profile

        profile = ProfileApi(linkedin).getMyProfile(access_token=linkedin_access_token)

        try:
            user_profile = LinkedInUserProfile.objects.get(linkedin_uid=profile.id)
            user = user_profile.user
            return user
        except LinkedInUserProfile.DoesNotExist:
            # Create a new user
            username = "******" % profile.id

            if not user:
                user = User(username=username)
                user.first_name, user.last_name = (profile.firstname, profile.lastname)
                user.email = "%s@socialauth" % (username)
                user.save()

            userprofile = LinkedInUserProfile(user=user, linkedin_uid=profile.id)
            userprofile.save()

            auth_meta = AuthMeta(user=user, provider="LinkedIn").save()
            return user
Exemple #2
0
    def authenticate(self, linkedin_access_token, user=None):
        linkedin = LinkedIn(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET)
        # get their profile

        profile = (ProfileApi(linkedin).getMyProfile(
            access_token=linkedin_access_token))

        try:
            user_profile = (LinkedInUserProfile.objects.get(
                linkedin_uid=profile.id))
            user = user_profile.user
            return user
        except LinkedInUserProfile.DoesNotExist:
            # Create a new user
            username = '******' % profile.id

            if not user:
                user = User(username=username)
                user.first_name, user.last_name = (profile.firstname,
                                                   profile.lastname)
                user.email = '%s@socialauth' % (username)
                user.save()

            userprofile = LinkedInUserProfile(user=user,
                                              linkedin_uid=profile.id)
            userprofile.save()

            auth_meta = AuthMeta(user=user, provider='LinkedIn').save()
            return user
    def authenticate(self, linkedin_access_token):
        linkedin = LinkedIn(settings.LINKEDIN_CONSUMER_KEY, settings.LINKEDIN_CONSUMER_SECRET)
        # get their profile
        
        profile = ProfileApi(linkedin).getMyProfile(access_token = linkedin_access_token)

        try:
            user_profile = LinkedInUserProfile.objects.get(linkedin_uid = profile.id)
            user = user_profile.user
            return user
        except LinkedInUserProfile.DoesNotExist:
            # Create a new user
            username = '******' % profile.id
            user = User(username =  username)
            temp_password = User.objects.make_random_password(length=12)
            user.set_password(temp_password)
            user.first_name, user.last_name = profile.firstname, profile.lastname
            #user.email = '*****@*****.**'%(person.id)
            user.save()
            userprofile = LinkedInUserProfile(user = user, linkedin_uid = profile.id)
            #userprofile.access_token = linkedin_access_token.key
            userprofile.headline = profile.headline
            userprofile.company = profile.company
            userprofile.location = profile.location
            userprofile.industry = profile.industry
            userprofile.profile_image_url = profile.picture_url
            userprofile.url = profile.profile_url
            userprofile.save()
            auth_meta = AuthMeta(user=user, provider='LinkedIn').save()
            return user
    def authenticate(self, linkedin_access_token, user=None):
        linkedin = LinkedIn(settings.LINKEDIN_CONSUMER_KEY, settings.LINKEDIN_CONSUMER_SECRET)
        # get their profile
        
        profile = ProfileApi(linkedin).getMyProfile(access_token = linkedin_access_token)

        try:
            user_profile = LinkedInUserProfile.objects.get(linkedin_uid = profile.id)
            user = user_profile.user
            return user
        except LinkedInUserProfile.DoesNotExist:
            # Create a new user
            username = '******' % profile.id
            if not user:
                user = User(username =  username)
                temp_password = User.objects.make_random_password(length=12)
                user.set_password(temp_password)
                user.first_name, user.last_name = profile.firstname, profile.lastname
                user.email = '{0}@socialauth'.format(username)
                user.save()
            userprofile = LinkedInUserProfile(user = user, linkedin_uid = profile.id)
            userprofile.save()
            auth_meta = AuthMeta(user=user, provider='LinkedIn').save()
            return user