This example shows how to use Salesforce Streaming API.
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
-
Go to
PLATFORM TOOLS > Apps > App Manager
in a navigation tree at the left of Salesforce Setup screen -
Click
New Connected App
button at the upper right -
Enter
camelk_knative_source_salesforce
for Connected App Name -
Enter your email address for Contact Email
-
Check Enable OAuth Settings
-
Enter
https://login.salesforce.com/services/oauth2/success
for Callback URL -
Choose 2 OAuth scopes,
Access and manage your data (api)
andPerform requests on your behalf at any time (refresh_token, offline_access)
, then click Add button -
Click Save button and then click Continue button
-
You will be redirected to
Manage Connected Apps
page.Consumer Key
andConsumer Secret
are available in API section. UseConsumer Key
as aClient ID
andConsumer Secret
as aClient Secret
. -
Go to
PLATFORM TOOLS > Apps > Connected Apps > Manage Connected Apps
-
Click
Edit
next to thecamelk_knative_source_salesforce
-
In OAuth Policies section,
-
Choose
Relax IP restrictions
for IP Relaxation -
Choose
Refresh token is valid until revoked
-
-
Click
Save
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
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.
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!