h1. Force.com Play! Module

The Force.com Play! module allows you to easily build Play applications for Force.com users. The module provides Force.com authentication (using OAuth2) and a connector for the REST API. The module is currently in an early development stage.

h2. Usage

Add the module as a dependency in <code>conf/dependencies.yml</code>

<pre><code>require:
    - play
    - force -> 0.2
</code></pre>

Now you can write a secured controller like this:

<pre><code>package controllers;

import play.modules.force.Force;
import play.mvc.*;

@With(controllers.force.Secure.class)
public class Application extends Controller {

    public static void index() {
    	System.out.println("Hello: "+Force.forceApi(session).getIdentity().getFirstName());
    }
}
</code></pre>

The user will be redirected to log in at Force.com and once authenticated, the Play! application can access the Force.com API on behalf of the user.

The module gives access to all the functionality of the Force.com REST API Java library. That library itself is currently under development but it has support for basic CRUD and query operations. See <a href="https://github.com/jesperfj/force-rest-api">the README on github</a> for details on what you can do.

h2. Reserved Routes

The module will automatically add a new route on <code>/_auth</code>. Your application must not route to this path. It is reserved for the OAuth authentication flow.

