Esempio n. 1
0
def sign_in(request):
    # Authenticate using the API key and Secret
    RETURN_URL = "http://localhost:8000/sign_in/"
    authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
    authentication.authorization_code = request.GET.get('code')
    application = linkedin.LinkedInApplication(authentication)
    
    # Get the API access token
    tok = authentication.get_access_token()
    application = linkedin.LinkedInApplication(token=tok)

    # Render the user's profile data as JSON
    return render(request, 'sign_in.html', {'profile': application.get_profile()})
Esempio n. 2
0
 def get_resume_info(self, request, auth_code=None):
     """
     Get full information from a resume and add theses information to the session cache
     :param auth_code: the authentication code needed to request the linkedinAPI
     :param request: the request
     :param application: the application filled with access token
     """
     # if 'auth_code' not in request.session:
     self.authentication.authorization_code = auth_code
     request.session['auth_code'] = auth_code
     linked_authentication = self.authentication.get_access_token()
     logger.debug("We have the TOKEN : " +
                  str(linked_authentication.access_token))
     application = linkedin.LinkedInApplication(
         token=linked_authentication.access_token)
     data = application.get_profile()
     logger.debug("resume Data : " + str(data))
     request.session['firstName'] = data.get('firstName')
     request.session['lastName'] = data.get('lastName')
     request.session['headline'] = data.get('headline')
     contact, created = Contact.objects.get_or_create(
         first_name=data.get('firstName'),
         last_name=data.get('lastName'),
         headline=data.get('headline'))
     if created:
         contact.count = 1
     else:
         logger.debug("Not created :" + str(contact.count))
         contact.count = contact.count + 1
         logger.debug("New count :" + str(contact.count))
         contact.save()
Esempio n. 3
0
File: main.py Progetto: gridl/PyLify
 def __init__(self):
     try:
         f = open('token', 'r')
     except IOError:
         f = open('token', 'wb')
         pickle.dump([], f)
         f.close()
         f = open('token', 'r')
     tk = pickle.load(f)
     f.close()
     if not tk:
         auth_token()  # fetch authorization token
         if ST != config.STATE:
             print "CSRF Attack! Aborting.."
             exit(1)
         data = {
             'grant_type': 'authorization_code',
             'code': AT,
             'redirect_uri': config.REDIRECT_URL,
             'client_id': config.CLIENT_ID,
             'client_secret': config.CLIENT_SECRET
         }
         headers = {'Content-Type': 'application/x-www-form-urlencoded'}
         r = post(config.ACCESS_URL, data=data,
                  headers=headers).text  # fetch access token
         r = json.loads(r)
         token = r['access_token']
         tk = list(token)
         f = open('token', 'wb')
         pickle.dump(tk, f)
         f.close()
     else:
         token = ''.join(tk)
     self.app = linkedin.LinkedInApplication(token=token)
Esempio n. 4
0
def linkedin_view(request):
    authentication = linkedin.LinkedInDeveloperAuthentication(
        consumer_key=settings.LINKEDIN_CONSUMER_KEY,
        consumer_secret=settings.LINKEDIN_CONSUMER_SECRET,
        user_token=settings.LINKEDIN_USER_TOKEN,
        user_secret=settings.LINKEDIN_USER_SECRET,
        redirect_uri=settings.SITE_ROOT_URI,
        permissions=linkedin.PERMISSIONS.enums.values())

    application = linkedin.LinkedInApplication(authentication)
    profile_data = application.get_profile(selectors=[
        'id', 'first-name', 'last-name', 'headline', 'location',
        'num-connections', 'skills', 'educations', 'picture-url',
        'site-standard-profile-request', 'summary', 'positions', 'industry'
    ])
    group_data = application.get_memberships()
    network_updates_data = application.get_network_updates(
        types=LINKEDIN_NETWORK_UPDATE_TYPES)

    context = {
        'profile': profile_data,
        'groups': group_data,
        'network_updates': network_updates_data
    }

    return HttpResponse(content=json.dumps(context),
                        status=200,
                        content_type='application/json')
Esempio n. 5
0
def processLinkedInData(jobsite, searchstring, citytosearch, ziptosearch, lastDownloadedTime):
	authentication = linkedin.LinkedInDeveloperAuthentication('75ph7mwmqazlp9', 'wauOWNOXgZqBKBWo', '4468dda6-1a33-4007-a175-0e03dc72282b', 'a9aee8ab-984b-4a3d-b8e9-a4e459c7d10f', 
		'http:\\jeevansgadgets.com\getjoblist', linkedin.PERMISSIONS.enums.values())
	application = linkedin.LinkedInApplication(authentication)

	filename = '%sjoblist.txt' % jobsite
	joblistfile = open(filename, 'w')

	totalcount = 0
	loopcount = 20
	while loopcount == 20:
		print 'downloading %s-%s' % (totalcount, totalcount+20)
		loopcount = 0
		data = application.search_job(selectors=[{'jobs': ['id', 'customer-job-code', 'posting-date', 'active', 'company', 'position', 'site-job-url', 'location-description']}], 
			params={'active': 'true', 'facet': 'job-function,it', 'keywords': searchstring, 'count': 20, 'start': totalcount, 'postal-code': ziptosearch, 'country-code': 'US', 'distance': 50, 'sort': 'DD'})

		#print data

		if data["jobs"]["_total"] == 0:
			continue
		for job in data["jobs"]["values"]:
			loopcount = loopcount + 1
			totalcount = totalcount + 1
			date = datetime.datetime.strptime(str(job["postingDate"]["month"]) + '-' + str(job["postingDate"]["day"]) + '-' + str(job["postingDate"]["year"]), '%m-%d-%Y')
			url = job["siteJobUrl"].strip()
			url = re.sub('&trk.*', '', url)
			if date >= lastDownloadedTime:
				joblistfile.write(job["position"]["title"].encode('ascii', 'ignore').strip() + '\t' + url + '\t' + job["company"]["name"].encode('ascii', 'ignore').strip() + '\t' + '' + '\t' + job["locationDescription"].strip() + '\t' + date.strftime('%Y-%m-%d') + '\n')
Esempio n. 6
0
def sign_in(request):
    # Get the authorization URL from Linkedin
    RETURN_URL = "http://localhost:8000/sign_in/"
    authentication = linkedin.LinkedInAuthentication(
        API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
    application = linkedin.LinkedInApplication(authentication)
    return JsonResponse({'auth_url': authentication.authorization_url})
Esempio n. 7
0
def share_post(channel_id, comment, title, submitted_url, submitted_image_url,
               visibility_code):
    """
    Publish a message on a linkedin channel,
    :param channel_id: The id of the channel we want to publish to
    :param comment:  The description of the post
    :param title: The title of the post
    :param submitted_url: The link contained in the post
    :param submitted_image_url: The image contained in the post
    :param visibility_code: Describe who can see this post
    :return: True if the message is published else False
    """
    token = LinkedinTokens.get_token(LinkedinTokens, channel_id).__getitem__(0)
    print('share_post token ', token)
    application = linkedin.LinkedInApplication(token=token)
    print('submitted_url', submitted_url)
    if submitted_url is '':
        submitted_url = None
    if submitted_image_url is '':
        submitted_image_url = None

    application.submit_share(comment=comment,
                             title=title,
                             submitted_url=submitted_url,
                             submitted_image_url=submitted_image_url,
                             description="This is a sharing from Superform",
                             visibility_code=visibility_code)
    return True
def post(access_token,
         comment=None,
         title=None,
         description=None,
         submitted_url=None,
         submitted_image_url=None,
         visibility_code='anyone'):
    """
    Publishes the post using the python3-linkedin API
    :param access_token: the access token which allows publishing
    :param comment: the body of the article
    :param title: the title of the related image or link
    :param description:
    :param submitted_url: the link
    :param submitted_image_url: the image
    :param visibility_code: visibility of the post on LinkedIn (on
    'anyone' by default
    :return: returns the link to the post just created or an exception
    """
    import collections
    AccessToken = collections.namedtuple('AccessToken',
                                         ['access_token', 'expires_in'])
    authentication = get_linkedin_authentication()
    authentication.token = AccessToken(access_token, "99999999")
    application = linkedin.LinkedInApplication(authentication)
    profile = application.get_profile()
    print("User Profile", profile)
    try:
        resp = application.submit_share(comment, title, description,
                                        submitted_url, submitted_image_url,
                                        visibility_code)
        return resp
    except Exception as e:
        print(e)
        return False
Esempio n. 9
0
def get_connection_values(response, **kwargs):
    if not response:
        return None

    access_token = response['access_token']

    auth = linkedin.LinkedInAuthentication(None, None, None, None)
    auth.token = AccessToken(response['access_token'], response['expires_in'])
    api = linkedin.LinkedInApplication(auth)
    profile = api.get_profile(selectors=selectors)

    profile_url = profile['siteStandardProfileRequest']['url']
    image_url = profile['pictureUrl']

    return dict(
        provider_id=config['id'],
        provider_user_id=profile['id'],
        access_token=access_token,
        secret=None,
        display_name=profile['firstName'],
        full_name='%s %s' % (profile['firstName'], profile['lastName']),
        profile_url=profile_url,
        image_url=image_url,
        email=profile.get('emailAddress'),
    )
Esempio n. 10
0
def linkedinRedirection(request):
    print "I was here!!!"
    authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, perms)
    code = request.GET.get('code')
    authentication.authorization_code = code
    at = authentication.get_access_token()
    print at
    application = linkedin.LinkedInApplication(token=at[0])
    profile =  application.get_profile(selectors=['id', 'first-name', 'siteStandardProfileRequest', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations'])
    print profile 
#     # Step 3. Lookup the user or create them if they don't exist.
#     #firstname = profile['firstName']
#     #lastname = profile['lastName']
#     identifier = profile['id']
    print request.user
    page_user = get_object_or_404(User, username=request.user)
    print page_user
    #user = get_object_or_404(User, username=request.user)
    identifier = profile['siteStandardProfileRequest']['url']
    print identifier
    LinkedInProfile.objects.get_or_create(identifier=identifier,
                                                       user=page_user)
    page_user.profile.isLinkedinPresent = True
    page_user.profile.linkedin_url = identifier
    page_user.save()
    return render(request, 'core/add_linkedIn.html')
Esempio n. 11
0
def authenticate():
    credentials = get_credentials()
    authentication = linkedin.LinkedInDeveloperAuthentication(
        credentials['consumer-key'], credentials['consumer-secret'],
        credentials['user-token'], credentials['user-secret'],
        credentials['return-url'], linkedin.PERMISSIONS.enums.values())
    return linkedin.LinkedInApplication(authentication)
Esempio n. 12
0
def redir():
    authentication = linkedin.LinkedInAuthentication(
        API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
    application = linkedin.LinkedInApplication(authentication)

    if request.args.get('code', '') != '':
        authentication.authorization_code = request.args.get('code', '')
        authentication.get_access_token()
        profile = application.get_profile(selectors=[
            'id', 'first-name', 'last-name', 'location', 'distance',
            'num-connections', 'skills', 'educations', 'interests', 'courses',
            'following', 'related-profile-views', 'job-bookmarks',
            'certifications'
        ])
        skills = get_skills(profile)
        courses = get_courses(profile)
        input_values = list(set(skills + courses))
        # print input_values
        github_input_values = [
            'c', 'c++', 'java', 'data structures', 'algorithms'
        ]
        github_input_values = input_values[:10]
        stack_qn_recommendations = multilabelstack.query(input_values)
        github_recommendations = git_crawler.query(github_input_values)
        dump_json(stack_qn_recommendations, "linkedin/stackoverflow_qns.json")
        dump_json(github_recommendations, "linkedin/git_repos.json")
        return render_template('redir.html')
    else:
        print "No Auth Code\n"
        return render_template('redir.html')
Esempio n. 13
0
    def __init__(self, token_set, who):

        self.who = who
        #################################
        # Linked In keys                #
        #################################
        CONSUMER_KEY = token_set['CONSUMER_KEY']
        CONSUMER_SECRET = token_set['CONSUMER_SECRET']
        USER_TOKEN = token_set['USER_TOKEN']
        USER_SECRET = token_set['USER_SECRET']

        print "Connecting to linkedIn."
        auth = linkedin.LinkedInDeveloperAuthentication(
            CONSUMER_KEY,
            CONSUMER_SECRET,
            USER_TOKEN,
            USER_SECRET,
            'http://localhost',
            permissions=linkedin.PERMISSIONS.enums.values())
        print "Authenticating."
        self.lnk = linkedin.LinkedInApplication(auth)
        print "Getting %s's connections." % self.who
        self.load_linkedin_connections()
        print "Processing list."

        # load clean up mappings
        self.cleanup_company = {}
        self.cleanup_email = {}
        f = open("cleanup_company.txt")
        for line in f.readlines():
            x = line.split(":")
            self.cleanup_company[x[0]] = x[1]
            self.cleanup_email[x[0]] = x[2].strip()
        f.close()
Esempio n. 14
0
    def setup_linkedin_application(self, linkedin_client_id,
                                   linkedin_client_secret):
        """
        Sets up and returns a new LinkedInApplication that can be used to get data.
        Ensure that the LinkedIn app dashboard for the given client ID and client secret have
        the LINKEDIN_RETURN_URL at the top of this file in the 'Authorized Redurect URLs'
        """
        authentication = linkedin.LinkedInAuthentication(linkedin_client_id, linkedin_client_secret, LINKEDIN_RETURN_URL, \
            permissions=['r_basicprofile', \
                         'r_emailaddress', \
                         'rw_company_admin', \
                         'w_share'])
        print(
            "Open this URL in your browser and give permissions if necessary: "
            +
            authentication.authorization_url)  # open this url on your browser
        authentication.authorization_code = input(
            "After you are redirected, copy the entire URL from your address bar and enter it here: "
        ).replace(LINKEDIN_RETURN_URL + "?code=", "").split("&state=")[0]
        print("\n\n Your authorization code is: " +
              authentication.authorization_code)
        result = authentication.get_access_token()

        print("Your new Access Token:", result.access_token)
        print("Access Token Expires in (seconds):", result.expires_in)

        return linkedin.LinkedInApplication(authentication)
Esempio n. 15
0
def linkedin_extract(redirect_uri, return_url):
    #assumes linkedin_url is correct if not empty
    if redirect_uri == "":
        print "Error: Invalid redirect_uri. redirect_uri is empty. Exiting"
        return 0

    query = urlparse.urlparse(redirect_uri).query  #Parse uri
    url_dict = urlparse.parse_qs(query)

    if 'code' not in url_dict:
        print "Error: Code not found in redirect uri. Exiting"
        return 0

    authentication_code = url_dict['code']  #Get code

    authentication = linkedin.LinkedInAuthentication(
        __API_KEY, __API_SECRET, return_url,
        linkedin.PERMISSIONS.enums.values())

    authentication.authorization_code = authentication_code  #Set auth_code, lib does not do this smartly..

    authentication.get_access_token()  #Needed to access linkedin account info.
    application = linkedin.LinkedInApplication(authentication)  #Now get access

    # Extract user information
    # Only extract skills:
    #fields = 'skills'
    # Full extraction:
    fields = ("id," + "first-name," + "last-name," + "headline," +
              "picture-url," + "industry," + "summary," + "specialties," +
              "positions:(" + "id," + "title," + "summary," + "start-date," +
              "end-date," + "is-current," + "company:(" + "id," + "name," +
              "type," + "size," + "industry," + "ticker)" + ")," +
              "educations:(" + "id," + "school-name," + "field-of-study," +
              "start-date," + "end-date," + "degree," + "activities," +
              "notes)," + "associations," + "interests," +
              "num-recommenders," + "date-of-birth," + "publications:(" +
              "id," + "title," + "publisher:(name)," + "authors:(id,name)," +
              "date," + "url," + "summary)," + "patents:(" + "id," + "title," +
              "summary," + "number," + "status:(id,name)," + "office:(name)," +
              "inventors:(id,name)," + "date," + "url)," + "languages:(" +
              "id," + "language:(name)," + "proficiency:(level,name))," +
              "skills:(" + "id," + "skill:(name))," + "certifications:(" +
              "id," + "name," + "authority:(name)," + "number," +
              "start-date," + "end-date)," + "courses:(" + "id," + "name," +
              "number)," + "recommendations-received:(" + "id," +
              "recommendation-type," + "recommendation-text," +
              "recommender)," + "honors-awards," + "three-current-positions," +
              "three-past-positions," + "volunteer")

    data = application.get_profile(None, None, fields)
    try:
        with open(FILE_NAME, 'w') as outfile:
            json.dump(data, outfile)
    except IOError:
        print 'Error: Cannot open or write to', FILE_NAME
        return 0

    return 1
Esempio n. 16
0
def reinit_linkedin_repo(linkedin_email, linkedin_pass, api_key, api_secret):
    browser = BrowserFactory.create()
    auth_service = LinkedAuthorizationService(browser)
    token = auth_service.refresh_token(api_key, api_secret, linkedin_email,
                                       linkedin_pass)
    browser.quit()
    application = linkedin.LinkedInApplication(token=token)
    return LinkedInRepository(application)
Esempio n. 17
0
def get_api(connection, **kwargs):
    auth = linkedin.LinkedInAuthentication(kwargs.get('consumer_key'),
                                           kwargs.get('consumer_secret'), None,
                                           linkedin.PERMISSIONS.enums.values())
    auth.token = AccessToken(getattr(connection, 'access_token'),
                             getattr(connection, 'expires_in'))
    api = linkedin.LinkedInApplication(auth)
    return api
Esempio n. 18
0
def linkedin_callback(request):

    if request.method == "GET":
        code = request.GET.get("code", None)
        code = True
        if code:
            authentication = linkedin.LinkedInAuthentication(
                API_KEY, API_SECRET, RETURN_URL,
                linkedin.PERMISSIONS.enums.values())
            #authentication.authorization_code =code
            #token = authentication.get_access_token()
            token = "AQUVIvgggNBTubY5GCb06liOZigFlQhRCMGvJvCa7WvenfwewKm-3zVrf0BR0c16hr0kUPcQBmE9_vbarWfyNlUy4fAhrjxeqAnkoKGM30wqV5yX0ZFm0F11jjbAN5YGVGA5qc60w5biQs2fJedZ6GLdXulm4nQN4lTUVUJ6fKzYkq-TcI0"
            app = linkedin.LinkedInApplication(token=token)
            alumnies = Alumni.objects.all()
            if alumnies.count() > 0:
                for alumni in alumnies.iterator():
                    first_name = alumni.first_name
                    last_name = alumni.last_name
                    params = {
                        "first-name": first_name,
                        "last-name": last_name,
                        "school-name": "University of Toronto"
                    }
                    profile = app.search_profile(selectors=[{
                        "people": [
                            "first-name", "email-address", "last-name",
                            "positions", "educations"
                        ]
                    }],
                                                 params=params)
                    if profile['people']['_total'] == 0:
                        continue

                    if profile['people']['values'][0]['positions'][
                            '_total'] == 0:
                        if 'emailAddress' in profile['people']['values'][0]:
                            alumni.email = profile['people']['values'][0][
                                'emailAddress']
                            alumni.save()
                        continue
                    positions = profile['people']['values'][0]['positions'][
                        'values']
                    if len(positions) == 1:
                        alumni.position = positions[0]['title']
                        alumni.company = positions[0]['company']['name']
                    else:
                        for i in range(len(positions)):
                            if positions[i]['isCurrent'] == True:
                                alumni.position = positions[0]['title']
                                alumni.company = positions[0]['company'][
                                    'name']
                    if 'emailAddress' in profile['people']['values'][0]:
                        alumni.email = profile['people']['values'][0][
                            'emailAddress']
                    alumni.save()

                    #alumni.company= profile['companies']
    return redirect("/")
def get_from_linkedin_api(access_token_str):
    application = linkedin.LinkedInApplication(token=access_token_str)

    #Get own Profile
    my_profile = application.get_profile(selectors=[
        'id', 'first-name', 'last-name', 'location', 'industry',
        'num-connections', 'summary'
    ])
    print(my_profile)
Esempio n. 20
0
    def test(self):
        """
        Main test method for testing the extractors.
        """

        # Constants needed to test the extractor.
        # NOTE: The test is using a fake LinkedIn profile we created.
        # This means we know what names/skills should be returned and how many.

        # API keys
        CONSUMER_KEY = '77d39rnu0jgxhc'
        CONSUMER_SECRET = 'SRjbrl5ajSwkbpMH'
        USER_TOKEN = 'c87cfe99-0997-4393-bc8a-09bc60bbbaf4'
        USER_SECRET = '1e37a040-934a-4047-8852-4fdc5c378b7c'
        RETURN_URL = 'http://www.google.com'
        # Skills we have entered for the profile.
        NEEDEDSKILLS = [
            "PHP", "Python", "Management", "Scrum", "People Skills",
            "Synergies", "Love Of Learning", "Bearings", "Pipe", "COBOL",
            "Brain Tumors", "Testing", "Debugging", "Entertainment",
            "Enterprise Software"
        ]

        # Authenticate and create an application.
        authentication = linkedin.LinkedInDeveloperAuthentication(
            CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL,
            linkedin.PERMISSIONS.enums.values())
        application = linkedin.LinkedInApplication(authentication)

        # Extract the following fields from the profile.
        fields = "first-name,last-name,skills"
        data = application.get_profile(None, None, fields)

        # Get the fields we need from the JSON.
        firstname = data['firstName']
        lastname = data['lastName']
        skills = data['skills']
        totalSkills = skills['_total']
        skillList = skills['values']

        # Check of the names are correct and  that
        # the correct number of skills was returned.
        self.assertEqual(firstname, "test")
        self.assertEqual(lastname, "profile")
        self.assertEqual(totalSkills, 15)

        # Loop through the skills and check that they are what we expect.
        for skill in skillList:
            skillstr = skill['skill']['name']
            if not (skillstr in NEEDEDSKILLS):
                self.fail("Unexpected skill:" + skillstr)
            else:
                NEEDEDSKILLS.remove(skillstr)

        # Check that we did recieve all the expected skills.
        self.assertEqual(len(NEEDEDSKILLS), 0)
Esempio n. 21
0
 def __init__(self, user, *args, **kwargs):
     self.user = user
     self.social_token = SocialToken.objects.filter(
         app__provider='linkedin_oauth2',
         account__provider='linkedin_oauth2',
         account__user=user)
     token = self.social_token.get()
     self.linked_in = linkedin.LinkedInApplication(
         token=linkedin.AccessToken(token.token, token.expires_at))
     self.social_app = SocialApp.objects.filter(id=token.app.id)
Esempio n. 22
0
def success(name):
    API_KEY = '81mpzcy471ubsr'
    API_SECRET = 'p1sGHyX2hM6EKdpb'
    RETURN_URL = 'http://localhost:5000/success'
    authentication = linkedin.LinkedInAuthentication(
        API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
    print authentication.authorization_url  # open this url on your browser
    application = linkedin.LinkedInApplication(authentication)
    print application
    return 'welcome %s' % name
Esempio n. 23
0
def get_provider_user_id(response, **kwargs):
    if response:
        auth = linkedin.LinkedInAuthentication(None, None, None, None)
        auth.token = AccessToken(response['access_token'],
                                 response['expires_in'])
        api = linkedin.LinkedInApplication(auth)

        profile = api.get_profile(selectors=selectors)
        return profile['id']
    return None
Esempio n. 24
0
    def get_results(job_title, zip_code):

        API_KEY = '75i3mk2maw6ogl'
        SECRET_KEY = 'MDasUmDtjPbYa1I9'
        USER_TOKEN = '8faba2a7-e3a6-4727-b06b-a291ebbf8032'
        USER_SECRET = '99fde265-7fd3-4d53-8eb8-d0f6f979388c'
        RETURN_URL = ''

        authentication = linkedin.LinkedInDeveloperAuthentication(
            API_KEY, SECRET_KEY, USER_TOKEN, USER_SECRET, RETURN_URL,
            linkedin.PERMISSIONS.enums.values())

        application = linkedin.LinkedInApplication(authentication)
        selectors = [{
            'people': [
                'first-name', 'last-name', 'headline', 'picture-url',
                'public-profile-url'
            ]
        }]
        params = {
            'keywords': job_title,
            'postal-code': zip_code,
            'country-code': 'us'
        }
        linked = application.search_profile(selectors=selectors, params=params)

        links = linked['people']['values']

        results = []
        #application = linkedin.LinkedInApplication(authentication)
        #results = application.search_profile(selectors=[{'people': ['first-name', 'last-name', 'headline']}], params={'keywords': job_title})
        #res = application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'Analyst'})
        #print linkedin.LinkedInApplication.search_profile.url
        #results = application.search_job(selectors=[{'jobs': ['id', 'customer-job-code', 'posting-date']}], params={'title': 'python', 'count': 2})

        for link in links:
            try:
                results.append({
                    'title':
                    link['firstName'] + " " + link['lastName'],
                    'desc':
                    link['headline'],
                    'image':
                    link['pictureUrl'],
                    'url':
                    link['publicProfileUrl'],
                    'content_type':
                    'Meeting',
                    'id':
                    ''
                })
            except:
                a = 1
        return results
Esempio n. 25
0
def get_user_auth():
    RETURN_URL = ''
    auth = linkedin.LinkedInDeveloperAuthentication(
        CONSUMER_KEY,
        CONSUMER_SECRET,
        USER_TOKEN,
        USER_SECRET,
        RETURN_URL,
        permissions=linkedin.PERMISSIONS.enums.values())
    print "(+) Authenticating to LinkedIN "
    app = linkedin.LinkedInApplication(auth)
    return app
def auth():
    authentication = linkedin.LinkedInAuthentication(APPLICATON_KEY,
                                                     APPLICATON_SECRET,
                                                     RETURN_URL,
                                                     ['r_basicprofile'])
    auth_code = request.args.get('code', default=None, type=str)
    authentication.authorization_code = auth_code
    token = authentication.get_access_token().access_token

    li_application = linkedin.LinkedInApplication(token=token)
    print(li_application.get_profile())
    return redirect('/user')
Esempio n. 27
0
def linkedin_view(request):
    application = linkedin.LinkedInApplication(token=settings.LINKEDIN_TOKEN)
    profile_data = application.get_profile(selectors=['id', 'first-name', 'last-name', 'headline', 'location',
                                                      'num-connections', 'skills', 'educations', 'picture-url',
                                                      'site-standard-profile-request', 'summary', 'positions',
                                                      'industry'])

    context = {'profile': profile_data}

    return HttpResponse(content=json.dumps(context),
                        status=200,
                        content_type='application/json')
Esempio n. 28
0
    def __init__(self, user):

        try:
            if not user.is_social_network_enabled(network="linkedin"):
                raise ValueError("User has not enabled Twitter")

            else:
                self.api = linkedin.LinkedInApplication(
                    token=user.linkedin_access_token)
                self.baseurl = "https://www.feedcrunch.io/@" + user.username + "/redirect/"

        except:
            self.api = False
Esempio n. 29
0
    def __init__(self, config, testing):
        '''
        Initialize
        :param config:
        :param testing:
        '''
        self._config = config

        if not testing:
            self._linkedin = linkedin.LinkedInApplication(
                token=config['authentication_token'])
        self._visibility = config['visibility']
        self.set_common_opts(config)
 def token_renew_link(self):
     ret = ''
     if self.source == 'linkedin':
         authentication = linkedin.LinkedInAuthentication(
             LINKEDIN_API_KEY, LINKEDIN_API_SECRET, LINKEDIN_RETURN_URL,
             LINKEDIN_PERMISSIONS)
         # Optionally one can send custom "state" value that will be returned from OAuth server
         # It can be used to track your user state or something else (it's up to you)
         # Be aware that this value is sent to OAuth server AS IS - make sure to encode or hash it
         # authorization.state = 'your_encoded_message'
         ret = authentication.authorization_url  # open this url on your browser
         linkedin.LinkedInApplication(authentication)
     return ret