Newer Version Available
Step 5: Use the Connector with OAuth Bearer Token Login
This step uses 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 Force.com REST API Developer Guide.
-
Under the /src/main/java/ folder,
open the BearerTokenExample.java Java source file from
the example package folder.
-
Run the BearerTokenExample class, and provide the following argument
values.
Argument Value url The 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, you can supply a replay ID as the last argument to receive different events. 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 last 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.