Integrating LinkedIn Groups in grails application.

24 / Aug / 2012 by Vishal Sahu 1 comments

In one of my recent Grails application, i needed to integrate LinkedIn groups with the application.
In my previous post, we discussed about Integrating LinkedIn API in any grails application. To add a LinkedIn Group, we first need to authorize the LinkedIn account which has either created that group or is the member/admin of the group with the rights to publish new post in that group.

After obtaining linkedIn_token and linkedIn_secret as mentioned in this blog, we need to make another call to retrieve all the Linked Groups for that account.

Code to retrieve all the LinkedIn Groups is as :-

String apiKey = API_KEY obtained from registered LinkedIn Application
String apiSecret = API_SECRET obtained from registered LinkedIn Application

Map linkedInGroupMap = [:]

LinkedInAccessToken accessToken = new LinkedInAccessToken(linkedIn_token, linkedIn_secret)
LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(apiKey, apiSecret)
LinkedInApiClient linkedInClient = factory.createLinkedInApiClient(accessToken)
GroupMemberships groupMemberships = linkedInClient.getGroupMemberships()

groupMemberships.groupMembershipList.each {GroupMembership groupMembership ->
linkedInGroupMap[] =

So, the resulting map will contains the key, value pairs of linkedIn groups ID and Name.

Now we can store these Group IDs for making API calls to :-

#. Retrieve group’s profile details.
#. Read, Create, Like, Comment group posts

Example API call to retieve group’s discussion wall posts:


This will retrieve latest 30 group discussions in JSON format.

This worked for me. Hope this helps…:)

Useful Links:

Vishal Sahu


comments (1 “Integrating LinkedIn Groups in grails application.”)

Leave a Reply

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