In this post, I will show how you can connect with LinkedIn from your salesforce org using a small piece of code.

So, Get ready to do another integration with Salesforce.

Before we start playing with the code we need to create a Custom Setting where we will store Access Token and Expiry time so that we could use this while making the callouts.

Setup Custom Setting: –

Go to Setup -> Develop -> Custom Settings -> New -> Name it “LinkedIn Token Info

Custom Setting - LinkedIn

Create a VF page and Controller Class: –

Create an Apex class Name it “LinkedlnoAuthController

Go to Setup -> Develop -> Apex Classes -> New -> 

Next, Create a VF page that will do the Authorization with LinkedIn. Name it “LinkedlnoAuth“.

You will get the complete code from my GitHub Repo. Copy Apex Class and VF page code From Here.

After you created VF page Preview it, Copy the URL and paste somewhere into the notepad++ or any other text editor. URL will be something like below


Create an App in LinkedIn: –

Time to create a Connected App into LinkedIn developer account to get the Client Id (Consumer Key)  and Client Secret(Consumer Secret).

Go to LinkedIn Developer Console Create Application. Refer this link to get the complete picture of app configuration. You will get Client Id and Client Secret copy both and store in the text editor.

You LinkedIn app page will look like below

LinkedIn - Application

Make Required Changes into Apex Class: –

1 – Open LinkedlnoAuthController class replace redirect_URI with your VF page preview URI (line #10).

2 – Replace consumerKey with your client Id and consumerSecret with your Client Secret (line #8 and #9).

Now, we are all set to let’s do some testing and see if we have successfully integrated LinkedIn with Salesforce.

Open LinkedlnoAuth VF page and preview it. Click Connect with LinkedIn button, it will open a new screen asking your LinkedIn username and password

Connect with Linkedln

Linked Login

Enter your username and password then sign in Grant permission to Application -> Click Complete Authorization, a success message will show.

Linked Login.png

Now Click on Get Basic Info -> A basic information will show here in PAGE

Basic Info.png

Facing any issue let me know in the comment section.

Our Score
Click to rate this post!
[Total: 0 Average: 0]

10 thoughts on “LinkedIn – Salesforce Integration”

  1. Hi ,
    I do all the steps mentioned above . But at last while Complete Authorization i got the below error and and not able to proceed further


    Access Code: Access Code: data value too large: AQUcaxhKtzEyVEmhoDFDuepjsMUfGwM1T0OCMUhT7DWucf1pZBtno5avpt-zVJIyLlCW_VP2nrY9YBQoEjCbR_HOghcaqkN1TGTXik1XuLSImaQUOJAeaeJ1rPMnOILhZ9QPF3HYaYmYtfuv5HYNDmu40MJGBi-6lbu2kjU58TimJRXQiUl4PcfB8dqgFmLOZVqKB6hKvRo8xgAJH2Ulqm7Ls-H4MQMb4n656pmhihOVO340Wsk3og2Eh5gSTWhbAXFvme5rbVKGBOFuJ4PfqyFtMHlYZwDiK92sfZ3nHt8H5kQeOV8f5nouw-BmcUDm4zAsUzbs5E6_6gsBEKLY990ZIT0ENA (max length=255)
    Unexpected Error while communicating with LinkedIn API. Status OK and Status Code 200
    Congrattzzzzz….. You have done successfull Integration with Linkedln

    Unexpected Error while communicating with LinkedIn API. Status Bad Request and Status Code 400

    1. Hi Raheshwar,

      The Error is because the value of the access token length is 255 chars. To avoid the Error Please use Custom metadata OR custom instead of Custom Setting to store the access and refresh token and make the changes in the code accordingly.

      1. Hi Amit,
        I replaced the Access_Token__c with Access_Token_1__c and Access_Token_2__c. On authentication I split the access token into two segments and stored the segments into the two attributes. On retrieval, I retrieved the token segments from the attributes and concatenated them. Just seemed easier than using metadata and having to do SOQL calls.

  2. Hi Amit,

    Nice piece of work!

    Thought you might like to mention this step in your excellent user guide.

    Unauthorize endpoint: An Administer must go to Setup -> Administer -> Security Control -> Remote Site Setting and add Endpoint

    Thanks and regards,

  3. Hi Amit, first of all thank you for your work and for making this tutorial and the youtube video.
    I would like to know if you know what changes should be made to the controller in order to make the integration with Linkedin using their v2 API (the version 1 of the API cannot be used anymore).

    Thanks in advanced!

  4. Hello Amit
    Linkedin integration Working greate. But I need some help with that. I will create the contact of Linkedin connection. if you have any solution for this. I have tried but it will not work.

    1. Hey Ankit,

      For this, you need a company application and once your application is approved you can use connection API to get all the details. In a Normal application, you can not fetch connections.

      Thanks & Regards,

Leave a Reply