Thursday, July 6, 2017

Sitecore Social Connected - Linkedin ( Sitecore 8+ )

Getting LinkedIn Profile data using Sitecore connected.


In this blog post i will be showing how to get the profile data from LinkedIn using Sitecore Connected. 

I will be covering below points-
  • Adding application in LinkedIn.
  • Setting up LinkedIn application.
  • Setting up Sitecore to use LinkedIn connection
  • Adding and configuring login with LinkedIn rendering.
  • Code snippet for getting profile data.

Adding application in LinkedIn  


for creating a new application in LinkedIn navigate to https://www.linkedin.com/developer/apps
and click on create  application . Fill in the required fields and click on submit.


Setting Up LinkedIn application


After adding the application open the application and set the Authorized Redirect URLs:


Copy Client ID and Client Secret .. Hit Update after adding url.

Setting up Sitecore to use LinkedIn connection


Login to Sitecore open content editor. Navigate to /sitecore/system/Social/Applications/Default.
right click on Default item and insert new application.



 Add the Application ID and Application secret copied from LinkedIn application.Select the network as LinkedIn.





Save the item.


Adding and configuring login with LinkedIn rendering.


Once configuration is done now you can add the login with LinkedIn rendering(/sitecore/layout/Renderings/Social MVC/Connector/Login with LinkedIn) to your page.





After adding the rendering you need to configure few Rendering parameters as shown below.




Click Ok. save and publish your page

You should be able to view the login button of LinkedIn on your page click on the login button it will redirect you to LinkedIn Authentication page. Enter the credential and click on allow access it should redirect back to the url which you provided earlier on rendering parameter.




It will add one query string parameter called authResult . If value is success means the login is successful else login failed.




Code snippet for getting profile data.

Now when login is successful the social profile data from LinkedIn gets attached to the Sitecore context user.
we can get those data by using below code and use it in our website.




below is the set of  data we can get -






we can configure the key data to be fetched from Sitecore.Social.ProfileMapping.LinkedIn.config file present at app_config/include/social folder.