Skip to content

Instantly share code, notes, and snippets.

@amineds
Created April 8, 2019 20:44
Show Gist options
  • Save amineds/b33d391ea1a403ac7cd54dad981bef62 to your computer and use it in GitHub Desktop.
Save amineds/b33d391ea1a403ac7cd54dad981bef62 to your computer and use it in GitHub Desktop.
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
oauth2 : {
// you can change loginUrl to connect to sandbox or prerelease env.
loginUrl : 'https://test.salesforce.com',
clientId : '3MVG9T46ZAw5GTfUAOzUzNDlh9exRS6m94PR1.o95_Q6t.qo8vFZkGOI_oAm3maz3oWLZ9K8Tdb1HTmVYev6a',
clientSecret : 'DD7FE38C376FA2575F3BAFC9980CC879CFB10E84BD55FA72E426DFABCC509119',
redirectUri : 'http://localhost:3000'
}
});
conn.login('amine.benhamza@gmail.com', 'password', function(err, userInfo) {
if (err) { return console.error(err); }
// Now you can get the access token and instance URL information.
// Save them to establish connection next time.
console.log(conn.accessToken);
console.log(conn.instanceUrl);
// logged in user property
console.log("User ID: " + userInfo.id);
console.log("Org ID: " + userInfo.organizationId);
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment