1

We are writing a nodejs application which should execute some set of actions against SF org triggered by incoming http request coming from that org. Such request will contain base url and session id in a payload.

In order not to reinvent the wheel, we are thinking about calling standard SFDX utilities/commands (e.g. executing apex, deploying code etc.) right from inside that nodejs web app.

The challenge with such approach is how to authenticate a user in sfdx toolset having session id and base url. Typicall sfdx requires web browser based authentication, also can be configured using jwt tokens and connected app for e.g. ci purposes. There are also some dx plugins which let us log in by username/password combination. But we've found next to nothing so far in regards to triggering dx actions by session id. Are there any plugins available or other tricks to achieve this?

Any help would be appreciated.

2 Answers 2

1

As per SFDX Dev Guide you need to set instanceUrl in config and after that you can use access token in place of username.

But for this you need to set instanceUrl either globally or in SFDX project (one sfdx project for each different instanceUrl)

1
  • SFDX_INSTANCE_URL - name of the global variable to be set for future reference
    – wesaw
    Commented Aug 8, 2020 at 17:58
2

You might have better luck here using the jsForce library, which is what sfdx uses under the hood, I believe. This page should show you how to create a new connection using jsForce with a session Id and server url

1
  • 1
    Have considered that already. But there are a lot of functionality available in SFDX right away (i.e. via one single command, standard one or from custom plugin), which is not available directly in jsforce. That means we would need to do a lot of "low level" coding to mimic what SFDX already can do, that means - reinventing the wheel, higher probability to introduce errors, more time needed etc. Thinking whether it's possible to use jsforce as some sort of bridge for authentication, and then initialize SFDX with everything needed and continue working with commands.
    – wesaw
    Commented Aug 8, 2020 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .