How to access LinkedIn data using spring-social - Little Big Extra Skip to main content

How to access LinkedIn data using spring-social

How to access LinkedIn data using spring-social and spring boot

Introduction

Spring Social provides the capability which enables our application to interact with LinkedIn Rest API and get user data. Considering how popular social logins have become recently, it is a nice feature to have on your website.

Getting started

I would suggest you to first clone the as it does have required page structure and dependencies

Add Maven Dependencies

Add the spring-social-google dependency

Update the application.properties

Now update the application.properties with your secret and client key

Add the HTML for LinkedIn

Under src/main/resources/templates/connect you should have facebookConnect.html and facebookConnected.html, if you have cloned/downloaded the spring tutorial properly.
Again replace facebook with linkedin in HTML and save them as linkedinConnected.html and linkedinConnect.html or copy them as shown below. Make sure the scope is properly defined in your request.

linkedinConnect.html

linkedinConnected.html

Add a @Controller for LinkedIn

We need to add a rest controller so it can handle LinkedIn authorization requests

@RequestMapping(“/linkedin”), your application should run on localhost:port/linkedin to test this example

Add HTML to show user details

In src/main/resources add a file called “linkedin.html” at same level as “hello.html”

That’s all

Run the application on localhost: port/linkedin and you should be authenticated. Drop comments if you face any problem

Please note that this example works only for one user if you want to make it work for multiple users go through below link

If you want to change the default page flow (linkedinconnect.tml to connect/linkedinConnected.html),please follow below link

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami