Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save enreeco/8561770 to your computer and use it in GitHub Desktop.
Save enreeco/8561770 to your computer and use it in GitHub Desktop.
C.SF ={
LoginURL : 'https://login.salesforce.com/services/oauth2/token',
Username : process.env.SF_USERNAME,
Password : process.env.SF_PASSWORD,
ClientID : process.env.SF_CLIENTID,
ClientSecret : process.env.SF_CLIENTSECRET,
}
var options = {
//http://www.salesforce.com/us/developer/docs/api_rest/index_Left.htm#CSHID=quickstart_oauth.htm|StartTopic=Content%2Fquickstart_oauth.htm|SkinName=webhelp
url: (C.SF.LoginURL+'?username='+C.SF.Username
+'&password='+encodeURIComponent(C.SF.Password)
+'&client_id='+encodeURIComponent(C.SF.ClientID)
+'&client_secret='+encodeURIComponent(C.SF.ClientSecret)
+'&grant_type=password'),
headers: {},
method: 'POST',
};
console.log(options.url);
request(options, function(error, response, body) {
if(error){
console.log(error);
return callback(error);
}
console.log(body);
var token = JSON.parse(body);
return callback(null,token);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment