@@ -8,17 +8,41 @@ See the [official Pub/Sub API repo](https://github.com/developerforce/pub-sub-ap
88
99Install the client library with ` npm install salesforce-pubsub-api-client ` .
1010
11- Create a ` .env ` file at the root of the project for configuration. You may use either of these authentication flows:
11+ Create a ` .env ` file at the root of the project for configuration.
1212
13- - Username/password authentication
13+ Pick one of these authentication flows and fill the relevant configuration:
14+
15+ - User supplied authentication
16+ - Username/password authentication (recommended for tests)
1417- OAuth 2.0 client credentials
15- - OAuth 2.0 JWT Bearer
18+ - OAuth 2.0 JWT Bearer (recommended for production)
1619
17- > ** Warning** <br />
18- > Relying on a username/password authentication flow for production is not recommended. Consider switching to JWT auth or similar for extra security.
20+ ### User supplied authentication
21+
22+ If you already have a Salesforce client in your app, you can reuse its authentication information. You'll only need this minimalistic configuration:
23+
24+ ``` properties
25+ SALESFORCE_AUTH_TYPE =user-supplied
26+
27+ PUB_SUB_ENDPOINT =api.pubsub.salesforce.com:7443
28+ ```
29+
30+ When connecting to the Pub/Sub API, use the following method instead of the standard ` connect() ` method:
31+
32+ ``` js
33+ await client .connectWithAuth (
34+ accessToken,
35+ instanceUrl,
36+ organizationId,
37+ username
38+ );
39+ ```
1940
2041### Username/password flow
2142
43+ > ** Warning** <br />
44+ > Relying on a username/password authentication flow for production is not recommended. Consider switching to JWT auth for extra security.
45+
2246``` properties
2347SALESFORCE_AUTH_TYPE =username-password
2448SALESFORCE_LOGIN_URL =https://login.salesforce.com
@@ -40,7 +64,9 @@ SALESFORCE_CLIENT_SECRET=YOUR_CONNECTED_APP_CLIENT_SECRET
4064PUB_SUB_ENDPOINT =api.pubsub.salesforce.com:7443
4165```
4266
43- ### OAuth 2.0 JWT Bearer Flow
67+ ### OAuth 2.0 JWT bearer flow
68+
69+ This is the most secure authentication option. Recommended for production use.
4470
4571``` properties
4672SALESFORCE_AUTH_TYPE =oauth-jwt-bearer
@@ -56,7 +82,7 @@ PUB_SUB_ENDPOINT=api.pubsub.salesforce.com:7443
5682
5783Here's an example that will get you started quickly. It listens to a single account change event.
5884
59- 1 . Activate account change events in ** Salesforce Setup > Change Data Capture** .
85+ 1 . Activate Account change events in ** Salesforce Setup > Change Data Capture** .
6086
61871 . Create a ` sample.js ` file with this content:
6288
0 commit comments