LinkedIn – Salesforce Integration

on

|

views

and

comments

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

https://dreamhouse-a-dev-ed–c.ap5.visual.force.com/apex/LinkedlnoAuth

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.

https://www.youtube.com/watch?v=t58SvPEfjKA
Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

12 COMMENTS

  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

    Errors

    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
    CONFIRM
    Success:
    Congrattzzzzz….. You have done successfull Integration with Linkedln

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

    • 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.

      • 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.
        Cheers,
        Richard

  2. 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!

  3. 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.

    • 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,
      SFDCPanther

  4. Hi Amit,
    My Linkedin Integration is Working. But when it comes to Post Sharing, it is showing “Unexpected Error while communicating with LinkedIn API. Status Unprocessable Entity and Status Code 422” this error. I have used advanced v2 code .Please help me out. Thanks in advance

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential