Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 3.29 KB

README.adoc

File metadata and controls

66 lines (46 loc) · 3.29 KB

Salesforce Streaming API Example

This example shows how to use Salesforce Streaming API.

Configuring Salesforce

This examples uses OAuth 2.0 Refresh Token Flow, which requires 3 credentials collected from Salesforce - Client ID, Client Secret and Refresh Token. You will need to put your own credentials in src/main/resources/application.properties file.

Note
You might want to sign up with your own Developer account at developer.salesforce.com. After you have done that, you’ll need to create a Connected Application for your integration.
Note
This was written with Salesforce Lightening user interface. Classic user interface might have slightly different menu and/or workflow.

Here is an example workflow of creating a Connected Application and get required credentials. For more details, please check Salesforce online manual https://help.salesforce.com/articleView?id=extend_code_overview.htm&type=5

Creating a Connected Application

  1. Go to PLATFORM TOOLS > Apps > App Manager in a navigation tree at the left of Salesforce Setup screen

  2. Click New Connected App button at the upper right

  3. Enter camelk_knative_source_salesforce for Connected App Name

  4. Enter your email address for Contact Email

  5. Check Enable OAuth Settings

  6. Enter https://login.salesforce.com/services/oauth2/success for Callback URL

  7. Choose 2 OAuth scopes, Access and manage your data (api) and Perform requests on your behalf at any time (refresh_token, offline_access), then click Add button

  8. Click Save button and then click Continue button

  9. You will be redirected to Manage Connected Apps page. Consumer Key and Consumer Secret are available in API section. Use Consumer Key as a Client ID and Consumer Secret as a Client Secret.

  10. Go to PLATFORM TOOLS > Apps > Connected Apps > Manage Connected Apps

  11. Click Edit next to the camelk_knative_source_salesforce

  12. In OAuth Policies section,

    1. Choose Relax IP restrictions for IP Relaxation

    2. Choose Refresh token is valid until revoked

  13. Click Save

Getting an OAuth refresh token

In your browser go to the URL, with substituting the YOUR_CLIENT_ID_HERE with your connected application Consumer Key:

https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=YOUR_CLIENT_ID_HERE&redirect_uri=https://login.salesforce.com/services/oauth2/success&display=touch

Allow access to the application, and you’ll end up on a page with refresh_token, something like:

https://login.salesforce.com/services/oauth2/success#access_token=..&refresh_token=<refresh_token>&instance_url=...&issued_at=...&signature=...&scope=...&token_type=Bearer

How to run

You can run this example using

$ mvn compile camel:run

Custom topic name and operation flags

You can specify your topic name (salesforce.topic) and turn on/off each operation to be notified (for example, set true for camel.component.salesforce.config.notifyForOperationCreate to receive Contact created event) in src/main/resources/application.properties file.

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!