Providing a “Sign-in with LinkedIn” functionality using Scala

To integrate a “Sign in with LinkedIn ” functionality in your social project that is being built with Play 2.2.1, follow these steps ( this post summarizes the work done step by step).

1) Create a LinkedIn app (if you do not have one already)

Follow the link https://developer.linkedin.com/documents/quick-start-guide‎ and create an app. Enter all the details including Site URL . The Site URL could be something like http://www..com (but it should be a valid site’s URL)

Once you have saved this app , you would get a
API Key and secret .

Take a note of this
API Key and secret .
We would use them in our code.

2) If you are using Play, then add the
API Key, secret key & contextURL(callback URL) in application.conf file.

3) Download a LinkedIn login image from linkedin.png, & save it in “public/images” folder of app

4) Add following dependency in build.sbt (or Build.scala for Play 2.1.x or older versions)

“org.scribe”         % “scribe”         % “1.3.5”

5) Add following to routes file in conf folder

GET             /user/linkedin/login              controllers.LinkedInController.linkedinLogin
GET             /user/linkedin/callback        controllers.LinkedInController.linkedinCallback



6) Let us now create LinkedInController.scala to configure API Key , secret key and callbackURL . We would also use this scala file to request access token from LinkedIn .

7) Now let us create a template RedirectMain.scala.html which would show LinkedIn Login Page on clicking LinkedIn login link on login page .

8) Add LinkedIn login link in the login.scala.html.

Written by 

Himanshu Gupta is a lead consultant having more than 4 years of experience. He is always keen to learn new technologies. He not only likes programming languages but Data Analytics too. He has sound knowledge of "Machine Learning" and "Pattern Recognition".He believes that best result comes when everyone works as a team. He likes listening to Coding ,music, watch movies, and read science fiction books in his free time.

2 thoughts on “Providing a “Sign-in with LinkedIn” functionality using Scala

Leave a Reply

%d bloggers like this: