Janrain Plugin

  • Tags : social, janrain, openid, engage, rpx
  • Latest : 1.1.0
  • Last Updated: 22 November 2010
  • Grails version : 1.3 > *
  • Authors : Marcel Overdijk
1 vote
Dependency :
compile ":janrain:1.1.0"

Documentation

Summary

Installation

grails install-plugin janrain

Description

Introduction

The Janrain plugin uses the Janrain4j library to integrate the Janrain API in your Grails application.

The plugin does basically nothing more than just registering the EngageService and retrieving the configuration options from your project's Config.groovy.

Prerequisites

The plugin assumes you registered and configured your application at Janrain.com and you know the basics about the Janrain API.

Installation

grails install-plugin janrain

Quickstart

To get started quickly just run:

grails janrain-quickstart

The quickstart script will:

  • Add the required Janrain config properties to Config.groovy.
  • Replace the index.gsp with a default index.gsp including the embedded Janrain sign-in widget.
  • Create a TokenController which retrieves the Janrain authentication information and renders it as output in the response.
Modify the Janrain config properties in Config.groovy by copying the appropriate values from the Janrain.com application dashboard.

Then run "run-app" and you can test the complete Janrain sign-in flow.

EngageService

The quickstart already demonstrates how to use the EngageService to retrieve the authentication information of the signed-in user:

def engageService

..

def response = engageService.authInfo(token)

The quikstart just uses the plain JSON response, but you can access all authentication information fields from the response directly:

def response = engageService.authInfo(token)

response.profile.identifier response.profile.displayName response.profile.preferredUsername response.profile.email ..

The Janrain API provides much more than just retrieving the authentication information. It provides methods to map/unmap local primary keys, retrieve all mappings for a primary key, get all mappings, and send status / publish activity updates to the social network of the signed-in user.

Check out the EngageService Apidocs for a complete reference of all the methods available and the corresponding responses.

Configuration Options

Janrain needs a couple of configurations options which need to be set in Config.groovy:

janrain.apiKey = "<your-api-key>"
janrain.applicationID = "<your-application-id>"
janrain.applicationDomain = "<your-application-domain>"
janrain.tokenUrl = "http://localhost:8080/<your-application-name>/token"

The apiKey, applicationID and applicationDomain can be found on the Janrain.com application dashboard.

There are also some optional configuration options:

janrain.languagePreference = "<language>"
janrain.proxyHost = "<your-proxy-host>"
janrain.proxyPort = 80
janrain.proxyUsername = "<your-proxy-username>"
janrain.proxyUsername = "<your-proxy-password>"
janrain.connectTimeout = 30000
janrain.readTimeout = 60000

Read the Config Apidocs for more information about the Janrain configuration options.

Tag Library

Janrain4j comes bundled with a JSP tag library to include the Janrain sign-in widget or sign-in link on your page(s).

Include the JSP tag library in your GSP pages by including the following taglib directive:

<%@ taglib prefix="janrain" uri="http://janrain4j.googlecode.com/tags" %>

And include e.g. the embedded sign-in widget like:

<janrain:signInEmbedded />

Read the tag library docs for more information about the available tags and it's configuration attributes.

References

If you want to integrate Janrain in non-Grails web projects (e.g. plain servlets, Spring, ..) then checkout the Janrain4j Java library.

Release Notes

1.1.0

2010-11-22
  • Upgraded to Janrain4j 1.1.0

1.0.2

2010-10-20
  • Upgraded to Janrain4j 1.0.2

1.0.1

2010-10-19
  • Initial release