I have worked on register a user with facebook via register plugin. I want to share my experience. Register plugin provide quick and easy solution for registration with your web application with facebook account.
At first you need to get app secret key and id from facebook using Facebook App link.
You can register using javascript and xfbml.Both I used xfbml, I am gonna tell you how to register using xfbml.
For this you should go to your html page and follow these steps.
Firstly You need to initialize your xfbml on your page using javascript.

<script type="text/javascript">
window.fbAsyncInit = function () {
appId: 'yourFacebookAppId',
status: true,
xfbml: true

(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

It will initialize xfbml on your page.
Now you just need to provide a xfbml tag to make UI . It will automatic generate a form of facebook.

<fb:registration redirect-uri="applicationUrl/controllerName/actionName"
fields='["{ "name":"name" },n" +
"             { "name":"email" },n" +
"             { "name":"first_name"},n" +
"             { "name":"last_name"},n" +
"             { "name":"gender" },n" +
"             { "name":"birthday" },n" +
"             {"name":"title","description":"Title", "type":"select","options":" +
"             {"Mr.":"Mr.","Mrs.":"Mrs.","Miss":"Miss","Ms.":"Ms."," +
"              "Dr.":"Dr.","Rev.":"Rev.","Prof.":"Prof."}},n" +
"             {"name":"password"}"]'

It has three mandatory field which you must provide for registration.
1. Redirect-uri: you must provide redirect uri, because after successful authentication facebook will redirect in your application with signd_request in which all your data will be in encoded format.
2. Fields: For registration you need to provide name field at first place, after that you can arrange all your field according to your requirement.
In this Fields attribute name, email,first_name,last_name and gender will provide by user’s facebook account.It will be automatic filled and disabled. Also you can define some custom field as I defined here like title(drop down). which will be blank at initial level and fill by user. For password you need to provide {“name”:”password”}. It will generate two field(appName Password and Re-enter password). This password field will have different password value from your facebook password.
Note: If you are using password field then you need to enter at least 8 character. Otherwise your register will not work and also not show any error message.
3. onvalidate: If you have some custom field in registration form like password etc. Then you need to provide validation at client side.
If you have some custom field then you need to validate it at client side. Otherwise facebook will not show any error at server side and create a hectic for developer.

<script type="text/javascript">
window.validate = function (form) {
var errors = {};
if (form.title == -1) {
errors.title = "Please fill title";
if (!form.password) {
errors.password = "Please fill password.";
} else if (form.password.length <= 7) {
errors.password = "password should be greater than or equal to 8 character.";

if (!form.password_confirmation) {
errors.password_confirmation = "Please fill confirm password.";
} else if (form.password_confirmation.length <= 7) {
errors.password_confirmation = "confirm password should be greater than or equal 8 character.";
if (form.password != form.password_confirmation) {
errors.password_confirmation = "Password does not match with confirm password."
return errors;

Where form is registration form , form.password show password field of form. Errors return a map of errors and it show error at corresponding fields. e.g. if errors.password has a value, it will show error next to password field.

The data is passed to your application as a signed request. The signed_request parameter is a simple way to make sure that the data you’re receiving is the actual data sent by Facebook. It is signed using your application secret which is only known by you and Facebook. If someone were to make a change to the data, the signature would no longer validate as they wouldn’t know your application secret to also update the signature. Now you need to decode your data and need to save it in your database.

def facebookRegistration() {
if (params.signed_request) {
def jsonData
try {
jsonData = registerService.getJsonData(params.signed_request)
} catch (Exception exception) {
log.debug "exception while trying to get json data from " + exception
// play with json data.

registerService is a service class where is a method to get JSON data from signed_request.

package  com.vivek
import org.json.JSONException
import org.json.JSONObject
import sun.misc.BASE64Decoder

class RegisterService {

def getJsonData(String signed_request) {
int count = 0;
String payload = null;
//The parameter contains encoded signature and payload separated by ‘.’
StringTokenizer st = new StringTokenizer(signed_request, ".");
//Retrieve payload (Note: encoded signature is used for internal verification and it is optional)
while (st.hasMoreTokens())
if(count == 1)
payload = st.nextToken();

//Initialize Base64 decoder
BASE64Decoder decoder = new BASE64Decoder();
//Replace special character in payload as indicated by FB
payload = payload.replace("-", "+").replace("_", "/").trim();
byte[] decodedPayload = decoder.decodeBuffer(payload);
payload = new String(decodedPayload, "UTF8");
catch (IOException e)
println("ERROR: Unable to perform Base64 Decode");
throw e;
//JSON Decode - payload
JSONObject payloadObject
payloadObject = new JSONObject(payload);
String facebookId = "" + payloadObject.get("user_id"); //Retrieve user ID
String oauthToken = "" + payloadObject.get("oauth_token"); //Retrieve oauth token
catch (JSONException e)
log.debug("ERROR: Unable to perform JSON decode");
throw e;
log.debug "first name-----------" + payloadObject.registration?.first_name
return payloadObject


Now you have data in json format. You can do whatever you want.
For more information you can visit facebook developer site
Hope it will hep you.