node package manager


Sales Force RESTful client


Sales Force RESTful proxy


sfaClient provides a connect based middle ware proxy for accessing Sales Force's RESTful API from a HTTP client. It currently allows for OAuth authentication. It also provides callbacks for getting the initial authentication information from the Sales Force configuration screen. It also provides a callback for storing and retrieving the access token information returned by Sales Force.

The following code is an example of a server that stores the client information and access token via mongodb. SSL is required to handle the OAuth callback.


var connect = require("connect"); var app = connect.createServer({ key: fs.readFileSync('mykey.pem'), cert: fs.readFileSync('mycert.pem')}); var sfaClient = require("sfaClient");

function saveSfaTokens(userid,tokens,callback) { db.collection('sfatokens',{},function(err,collection) { if(err) return callback(err); tokens.userid=userid; tokens.modifiedAt =; return collection.update({userid: userid},tokens,{upsert:true},function(err) { return callback(err); }); });

function getSfaTokens(userid,callback) { db.collection('sfatokens',{},function(err,collection) { if(err) callback(err,undefined); collection.findOne({userid: userid},function(err,tokens) { if(err) { callback(err,undefined); } else { callback(undefined,tokens); } }); }); };

function getSfaClientId(req,callback) { if(req.remoteUser) { return callback(null,{ client_id: req.remoteUser.sfa.consumerKey, client_secret: req.remoteUser.sfa.consumerSecret, redirect_uri: req.remoteUser.sfa.callbackUrl }); } return callback('RemoteUser is not defined',null); };

app.use(sfaClient.listen({ root: '/sfa/', getClientId: getSfaClientId, saveTokens: saveSfaTokens, getTokens: getSfaTokens }));



$ npm install sfaClient


Released under the Apache License 2.0

See LICENSE file.

Copyright (c) 2011 Donald Lamar Davis II