Newer Version Available
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 Authentication with OAuth 2.0. Also see Authenticate Apps with OAuth in Salesforce Help and Understanding Authentication in the REST API Developer Guide.
-
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 topic /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.