How to get Connected With LinkedIn in Grails ??

Following are the steps to get connected to linkedIn in grails:

1. First of all install oauth plugin ,


 runtime “:oauth:2.1.0″


alternatively install it by grails install-plugin oauth

2. In Config.groovy file, add following

oauth {
providers {
linkedin {
api = org.scribe.builder.api.LinkedInApi
key = ‘xxx’
secret = ‘yyy’

callback = “http://localhost:8080/test2/oauth/linkedin/callback”
successUri = “http://localhost:8080/test2/oauthCallBack/linkedin”

failureUri = “http://localhost:8080/test2/oauthCallBack/linkedinFailure”

requestTokenUrl = “”
accessTokenUrl = “”
authUrl = “”

grails.linkedin.api.url = “,first-name,last-name,email-address,date-of-birth)?format=json”

3. In your GSP file add this ,


<oauth:connect provider=”linkedin”>Connect</oauth:connect>

4. Add handler for response, i.e. edit  OauthCallBackController  as following:

def linkedin() {
Token linkedinAccessToken = (Token)          session[oauthService.findSessionKeyForAccessToken('linkedin')]
def linkedInResponse = oauthService.getLinkedInResource(linkedinAccessToken, grailsApplication.config.grails.linkedin.api.url)
def linkedinParsedResponse = JSON.parse(linkedInResponse?.getBody())

User user = User.findByLinkedInId(linkedinParsedResponse['id'])
if (user) {
} else {


def linkedinFailure() {
render “I am back..,.”

ProsperaSoft offers Grails development solutions. You can email at to get in touch with ProsperaSoft Grails experts and consultants.

Leave a Reply

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


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>