Newer Version Available
(Optional) Step 5: Use the Connector with OAuth Bearer Token Login
You can use the connector with OAuth authentication as an alternative to username and
password authentication. This step is optional and requires an OAuth token.
Prerequisites
Obtain an OAuth bearer access token for your Salesforce user. You supply this access token in the connector example.See Set Up Authorization with OAuth 2.0. Also see Authorize Apps with OAuth in Salesforce Help.
-
In the
/src/main/java/com/salesforce/emp/connector/example
folder, open the BearerTokenExample.java Java source
file.
-
Run the BearerTokenExample class, and provide the following argument
values.
Argument Value url URL of the Salesforce instance of the logged-in user token The access token returned by the OAuth authentication flow channel The channel name for the PushTopic: /topic/InvoiceStatementUpdates The sample fetches the earliest saved events within the past 24 hours. Optionally, to receive different events, you can include a replay ID as the last argument. Valid values are:- –1—Get all new events sent after subscription.
- –2—Get all new events sent after subscription and all past events within the past 24 hours.
- Specific number—Get all events that occurred after the event with the specified replay ID.
-
In a browser window, create or modify an invoice statement. After you create or
change data that corresponds to the query in your PushTopic, the output looks
similar to the following.