Salesforce.getAccessToken()

Generate a new access token for acting on behalf of a particular Salesforce user account.

Note that you must first have a valid `code` from the user proving that they're OK with this. You can get a code by redirecting the user to the url generated by calling the `getLoginUrl(...)` machine.

Usage

Hover over inputs/exits for more info.

var Salesforce = require('machinepack-salseforce-expanded');


// Generate a new access token for acting on behalf of a particular Salesforce user account.

Salesforce.getAccessToken({

consumerKey: 'adf90878aKsloewurSDFIUFsdisoufsodfu',

consumerSecret: 'dsg4901g0123456',

callbackUrl: 'http://localhost:1337/auth/login',

code: 'AQDvCav5zRSafS795TckAerUV53xzgqRyrcfYX2i_PJF9QOe_md7h5hy2gMhOS6TL9IBk5qxMA2q_8EJxGPTqEbmTqOBqqCIOlvPEPCeIiy21VD9_Y',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

consumerKey required

The consumer key for your Salesforce app.

'adf90878aKsloewurSDFIUFsdisoufsodfu'
consumerSecret required

The developer "secret" for your Salesforce app (i.e. this "Consumer Secret" is listed on your app's dashboard page in the Salesfore app portal)

'dsg4901g0123456'
callbackUrl required

The callback URL where the end user will be redirected after visiting the login URL returned by this machine

'http://localhost:1337/auth/login'
code required

The OAuth `code` generated by Salesforce and sent to the `callbackUrl` if the user chooses to grant your app the requested permissions

'AQDvCav5zRSafS795TckAerUV53xzgqRyrcfYX2i_PJF9QOe_md7h5hy2gMhOS6TL9IBk5qxMA2q_8EJxGPTqEbmTqOBqqCIOlvPEPCeIiy21VD9_Y'

Exits

error

An unexpected error occurred.

success

OK.

{ id: 'https://login.salesforce.com/id/89Ej0749aEIU/2342l888888D7',
  issued_at: '2183487234723',
  scope: 'id api web refresh_token',
  instance_url: 'https://na16.salesforce.com',
  token_type: 'Bearer',
  refresh_token: '8Bfo973F7FSDdkiUYUyosdyfODI_sdkdhfIPWEdJK',
  signature: 'dkdhfIPWEd=Bfo973F7F',
  access_token: 'cxRiJv_eVFRXgJyTGnCQ5Wb!AQkAQOcxRiJv_eVFRXgNpgo9JH2sDxVWNyg.fJyTGnCQ5Wbnkpm1wuHajiI9yqoGhdF61NIJCJkiNpgo9JH2s' }