PK PF?LU; ; build.xml
PK PF?5 5 commands.py# Here you can create play commands that are specific to the module, and extend existing commands
MODULE = 'force'
# Commands that are specific to your module
COMMANDS = ['force:hello']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "force:hello":
print "~ Hello"
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass
PK ?b commands.pyc
Nc @ s. d Z d g Z d Z d Z d Z d S( t forces force:helloc K sV | i d } | i d } | i d } | i d } | d j o d GHn d S( Nt commandt appt argst envs force:hellos ~ Hello( t get( t kargsR R R R ( ( sa /Users/jjoergensen/dev/play-modules/force/samples-and-tests/sample-app/../../../force/commands.pyt execute s
c K s@ | i d } | i d } | i d } | i d } d S( NR R R R ( R ( R R R R R ( ( sa /Users/jjoergensen/dev/play-modules/force/samples-and-tests/sample-app/../../../force/commands.pyt before s c K sQ | i d } | i d } | i d } | i d } | d j o n d S( NR R R R t new( R ( R R R R R ( ( sa /Users/jjoergensen/dev/play-modules/force/samples-and-tests/sample-app/../../../force/commands.pyt after s
N( t MODULEt COMMANDSR R R
( ( ( sa /Users/jjoergensen/dev/play-modules/force/samples-and-tests/sample-app/../../../force/commands.pyt s PK h?i@$ $ manifestversion=0.3
frameworkVersions=1.2.4
PK ?WG+ + README.md# Force.com module for Play! Framework
# Usage
This module is not yet registered as an official Play! module and it depends on a fork of the Force.com WSC module. So here's how to build it and test it:
## Clone this repo
$ git clone git@github.com:jesperfj/force-play-module.git force
## Build the module
$ cd force
$ play deps && play build-module
## Set up OAuth config
You'll need a Force.com developer account. If you don't have one [go and sign up now](http://www.developerforce.com/events/regular/registration.php?d=70130000000EjHb) (it's free).
Once you have an account, sign in and:
1. Click on "Admin User" drop-down in upper-right
2. Select Setup
3. In the left-side navigation pane, under "App Setup", click on "Develop"
4. Select "Remote Access"
5. Click on "New"
6. Choose any name for your application
7. Choose any callback URL (you'll need to set this properly when web server flow is supported)
8. Choose some contact email
9. Click "Save"
10. Copy "Consumer Key" for use later
11. Click on "Click to reveal" and copy "Consumer Secret" for use later.
Now set up environment variables using the consumer key and secret:
$ export FORCE_OAUTH_KEY="consumer key"
$ export FORCE_OAUTH_SECRET="consumer secret"
$ export APP_URI="http://localhost:9000"
`APP_URI` is necessary to determine redirect URI. You must set redirect URI in remote access config to `http://localhost:9000/_auth`
### Test it out
$ cd samples-and-tests/sample-app
$ play deps --sync
$ play run
Hit and see what happens.
PK ?mӼ ) app/controllers/force/Authentication.javapackage controllers.force;
import play.mvc.Controller;
import com.force.api.ApiConfig;
import com.force.api.ApiSession;
import com.force.api.Auth;
import com.force.api.AuthorizationResponse;
public class Authentication extends Controller {
public static void index() {
ApiSession s = Auth.completeOAuthWebServerFlow(new AuthorizationResponse()
.apiConfig(new ApiConfig()
.setClientId(System.getenv("FORCE_OAUTH_KEY"))
.setClientSecret(System.getenv("FORCE_OAUTH_SECRET"))
.setRedirectURI(System.getenv("APP_URI")+"/_auth"))
.code(params.get("code")));
session.put("force_auth", s.getAccessToken()+" "+s.getApiEndpoint());
redirect(params.get("state"));
}
}
PK ?Y Y ! app/controllers/force/Secure.javapackage controllers.force;
import play.mvc.Before;
import play.mvc.Controller;
import com.force.api.ApiConfig;
import com.force.api.Auth;
import com.force.api.AuthorizationRequest;
public class Secure extends Controller {
@Before
public static void checkAuthenticated() {
if(session.get("force_auth")==null) {
redirect(Auth.startOAuthWebServerFlow(new AuthorizationRequest()
.apiConfig(new ApiConfig()
.setClientId(System.getenv("FORCE_OAUTH_KEY"))
.setRedirectURI(System.getenv("APP_URI")+"/_auth"))
.state(System.getenv("APP_URI")+request.url)));
}
}
}
PK Hg?` conf/dependencies.ymlself: play -> force 0.3
require:
- play 1.2.4
- com.force.api -> force-rest-api 0.0.7
repositories:
- forcerestapi:
type: iBiblio
root: "http://jesperfj.github.com/force-rest-api/repository/"
contains:
- com.force.api -> force-rest-api
PK PF?*<