Skip to main content

Integration with LinkedIn using Mule ESB

Overview

LinkedIn is a business-oriented social networking service. LinkedIn was founded in December 2002 and launched on May 5, 2003. It is mainly used for professional networking. In this blog post,  a step by step procedure is shown for integrating LinkedIn with Mule ESB LinkedIn connector.

Versions and Assumptions

  • In this blog post, we are using
    • LinkedIn Connector 1.1.0
    • Anypoint Studio
    • Mule ESB Server 3.5.2
  • To use this application in the project, a LinkedIn account is necessary for testing
  • We need to create a new LinkedIn app under LinkedIn developer apps to be able to communicate with the LinkedIn account from Mule ESB application
  • In this blog post, we will be using OAuth2 authentication to connect to LinkedIn using Mule ESB LinkedIn Connector

Configuring LinkedIn App

  • Go to https://www.linkedin.com/secure/developer
  • Click on Add new Application
  • Fill in the form and click on Add Application
  • Make a note of the consumer key, consumer secret and the OAuth2 Redirect URL as these will be used during our Mule ESB application configuration
  • Click on Done

A sample screen shot is given below

AppRegister_1

Integration with LinkedIn using Mule ESB

AppRegister_2

Integration with LinkedIn using Mule ESB

LinkedIn API Details

Integration with LinkedIn using Mule ESB, LinkedIn API Details

Configuring LinkedIn Connector

  • Create a new Mule Application
  • Click on Global Elements tab in your main flow
  • Click on Create Button
  • Select LinkedIn under Connector Configuration group
  • Add LinkedIn consumer key value to API Key text box
  • Add LinkedIn consumer secret value to API Secret text box
  • Add “r_basicprofile,r_network” in the scope text box
  • Click on Oauth tab and specify domain, local port, remote port and Path values
  • The Oauth values should be same as what is configured in LinkedIn App

A sample screen and XML configuration is given below:

LinkedIn Connector_1

Integration with LinkedIn using Mule ESB

LinkedIn Connector_2

Integration with LinkedIn using Mule ESB
<linkedin:config name="LinkedIn_Confog" apiKey="${apiKey}"
apiSecret="${apiSecret}" doc:name="LinkedIn" scope="r_basicprofile,r_network">
<linkedin:oauth-callback-config domain="localhost"
localPort="3333" remotePort="3333" path="linkedinauthorize" />
</linkedin:config>

Mule Flow for LinkedIn Authentication and getting user profile

  • Configure a flow as given below
Integration with LinkedIn using Mule ESB
<flow name="linkedinconnectFlow1" doc:name="linkedinconnectFlow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="3300" doc:name="HTTP" path="linkedinconnect" />
<linkedin:authorize config-ref="LinkedIn_Confog"
doc:name="Authorize" />
<logger message="#[flowVars]" level="INFO" doc:name="Logger" />
</flow>
<flow name="linkedinconnectFlow2" doc:name="linkedinconnectFlow2">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="3300" path="getuser" doc:name="HTTP" />
<linkedin:get-profile-by-url config-ref="LinkedIn_Confog"
url="https://www.linkedin.com/pub/rupesh-sinha/23/350/200"
profileType="PUBLIC" doc:name="LinkedIn">
<linkedin:profile-fields>
<linkedin:profile-field>FIRST_NAME</linkedin:profile-field>
<linkedin:profile-field>LAST_NAME</linkedin:profile-field>
</linkedin:profile-fields>
</linkedin:get-profile-by-url>
<json:object-to-json-transformer
doc:name="Object to JSON" />
<logger message="#[payload]" level="INFO" doc:name="Logger" />
</flow>

Testing and Observation

  • Deploy the mule application
  • Hit the following URL on the browser

http://localhost:3300/linkedinconnect

  • LinkedIn will ask us to authorize the new app to connect to LinkedIn as shown below
  • Provide the username and password
  • Click on Allow access
  • We should now see “oauth_token” and “oauth_verifier” values printed on our browser
  • Now hit the below URL

http://localhost:3300/getuser

  • We should now see the user public profile details printed on your browser in JSON format

If you would like to find out more about how Systems Integration could help you make the most out of your current infrastructure while enabling you to open your digital horizons, do give us a call at +44 (0)203 475 7980 or email us at Salesforce@coforge.com

Other useful links:

Integration with Twitter using Mule ESB

Integration of Mule ESB with Microsoft Azure

Integration with Dropbox using Mule ESB

Let’s engage