Integration Of Linkedin API in python django

Reading Time : ~ .

Using Linkedin integration by Django, we can get the user verified email id, general information, work history in a less span of time, and a user can also share articles.

These Following steps are needed for Linkedin integration:

    1. creating LinkedIn app
    2. Authenticating user and getting an access token.
    3. Get user information, work history using access token.

1. Creating Linkedin App

          a. To create an app, click on create an application on top of a page(https://www.linkedin.com/developer/apps).

              Here you can give application name, description, logo, email, website url, then the application will be created.

          b. Now you can get the client id, secret of an application and you can select application permission like basic profile,

              email address, company admin, can share an article.

2. Authenticating user and getting an access token.

         a. Here We have to create a GET request for asking user permission.

   GET "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=LN_API_KEY&scope=r_basicprofile r_emailaddress rw_company_adminw_share&state=8897239179ramya&redirect_uri=Redirect_URL"

         LN_API_KEY: your application client id,
         SCOPE: List of permissions to request from the person using your app
         REDIRECT_URI: The URL which you want to redirect after user login

         b. If a user accepts the permissions, then authorization code send to redirected url.
         c. Then we get an access token using the Urllib with following params.

       params = {
                  'grant_type' = 'authorization_code',
                  'code' = 'Your Authorization Code'
                  'redirect_uri' = 'Redirect Url',
                  'client_id' = 'Your Application Client id',
                  'client_secret' = 'Your Application Client secret key',
       }
       params = urllib.urlencode(params)
       info = urllib.urlopen("https://www.linkedin.com/uas/oauth2/accessToken", params)
       accesstoken = json.loads(info.readline())['access_token']

3. Get user information using access token.

   rty = "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,location,positions,educations,industry,public-profile-url,picture-urls::(original))?format=json&oauth2_access_token={{Your Accesstoken}}"

   details = urllib2.urlopen(rty).read()
   details = json.loads(details)

    From the details, You can get the user linkedin id, profile url, first name, last name, work history, email.

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
How to Create initial django migrations for existing DB schema. Chaitanya Kattineni

Django provides the comfort database migrations from its version 1.8, with which we can avoid the usage of third party packages like south. Adding migrations ...

Continue Reading...
Add captcha to django web page using Python-reCaptcha Divya Sri

Python-reCaptcha is a pythonic and well-documented reCAPTCHA client that supports all the features of the remote API to generate and verify CAPTCHA challenges. To add ...

Continue Reading...
Django Raw Sql Queries Vamsi Popuri

When your model query API don't go well or you want more performance, you can use raw sql queries in django. The Django Object Relational ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties