A passport.js oauth strategy for ForceDotCom/DatabaseDotCom
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 2 commits ahead, 30 commits behind joshbirk:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.




This is a Strategy for use with http://passportjs.org with the Force.com platform (meaning you can use it with Saleforce CRM, your Force.com applications and Database.com). With Jared Hanson's help - it properly resolves a previous issue with handling the incoming OAuth information so that things like the instance_url can be readily available.


  1. Download this as npm module.
npm install passport-forcedotcom

2 Import it in your app.

var passport = require('passport')
  , ForceDotComStrategy = require('passport-forcedotcom').Strategy
  1. Define the strategy with your application credentials and information:
passport.use(new ForceDotComStrategy({
   clientID: '{clientID}',
   clientSecret: '{clientSecret}',
   callbackURL: '{callbackUrl}'
 function(token, tokenSecret, profile, done) {
   return done(null, profile);
  1. And then setup some routes to hande the flow:
app.get('/login', passport.authenticate('forcedotcom'));
  passport.authenticate('forcedotcom', { failureRedirect: '/error' }),
  function(req, res){

And as usual with passport, you can update the user serialization/de-serialization.

###Example There is an example app called simple-example in: examples/ folder. This shows how to use ForceDotCom-Passport with lots of comments. To run locally:

  1. Open app.js in examples/simple-example
  2. Set CF_CLIENT_ID, CF_CLIENT_SECRET, CF_CALLBACK_URL and optionally, SF_AUTHORIZE_URL, SF_TOKEN_URL to match your connected app's settings.
  3. Install npm modules by running npm install
  4. Run: node app.js
  5. Open localhost:3000 in the browser and try to login using OAuth.

###Authors Joshua Birk & Raja Rao DV