<a id="salesforce-pushtopic-source-connector-quickstart"></a>

# Configure the Salesforce PushTopic Source Connector

This page includes the steps needed to configure the Salesforce PushTopics Source connector.

<a id="salesforce-pushtopic-source-connector-quickstart-preliminaries"></a>

<a id="salesforce-connector-quickstart-preliminaries"></a>

<a id="salesforce-connector-quickstart-preliminaries-account"></a>

# Salesforce Account

1. Use [https://login.salesforce.com/](https://login.salesforce.com/) to log into an existing account or create a new one.
2. Create a new Connected App.
   1. Select the gear icon in the upper right hand corner and choose **Setup**.
   2. Enter **App** in the **Quick Find** search box, and choose **App Manager** in the filtered results.
   3. Click the **New Connected App** button in the upper right corner of the Setup panel.
   4. Supply a **Connected App Name**, **API Name**, and **Contact Email**.
   5. Select **Enable OAuth Settings** checkbox and select the **Enable for Device Flow** checkbox. These selections enable the connector to use the Salesforce API.
   6. Under the **Select OAuth Scopes** field, select all of the items under **Available OAuth scopes** and add them to the **Selected OAuth Scopes**.
   7. Save the new app and press **Continue** at the prompt.
   8. Look for the **Consumer Key** and **Consumer Secret** in the displayed form. Save these so you can put them in the configuration properties file for the Salesforce connect worker.
3. Find your Security Token (emailed to you from Salesforce.com). If you need to reset your token or view your profile on Salesforce.com, select **Reset My Security Token** and follow the instructions.

Complete the following steps for JWT token bearer:

1. Log into the account at [https://login.salesforce.com/](https://login.salesforce.com/).
2. Go to the setup area (the gear icon, top right).
3. Go to **Apps** > **App Manager** (in the side navigation area).
4. Click **New Connect App**.
5. Populate the required **Basic Information** fields.
6. In the **API (Enable OAuth Settings)** section:
   * Check **Enable OAuth Settings**.
   * **Callback URL** is unused in the JWT flow, but it still requires a value.  Use “[http://localhost/](http://localhost/)” or any other sample host URL.
   * Check **Use digital signatures**. Upload the **salesforce.crt** that was generated earlier.
   * For **Selected OAuth Scopes**, add **Access and manage your data (api)** and **Perform requests on your behalf at any time (refresh_token, offline_access)**.
7. Click **Save**. If there are any errors, upload **salesforce.crt** again.
8. On the resulting app page, click **Manage**.
   - Click **Edit Policies**.
   - In the **OAuth policies** section, change **Permitted Users** to **Admin approved users are pre-authorized**.
   - Click **Save**.
9. In the **Profiles** section (on the app page), click **Manage Profiles**.
10. On the **Application Profile Assignment** page, assign the user profiles that may access the app.
11. Complete the following steps to get the Salesforce app **Consumer Key**:
    1. Log into the account at [https://login.salesforce.com/](https://login.salesforce.com/).
    2. Go to the setup area (the gear icon, top right).
    3. Go to **Apps** > **App Manager** (in the side navigation area).
    4. In the list, find the app that you created in the **App Creation** in a previous step.
    5. Click **View** from the app row drop-down selections. The **Consumer Ke** is in the **API (Enable OAuth Settings)** section.

<a id="salesforce-connector-quickstart-preliminaries-plugin"></a>

# Install the Salesforce Connector Plugin

Prerequisites
: - [Confluent Platform](/platform/current/installation/index.html)
  - [Confluent CLI](https://docs.confluent.io/confluent-cli/current/installing.html) (requires separate installation)

1. Navigate to your Confluent Platform installation directory and run this command to install the latest version of the Salesforce connector.
   ```bash
   confluent connect plugin install confluentinc/kafka-connect-salesforce:latest
   ```
2. Restart Connect to pick up the new plugin.
   ```bash
   confluent local services connect stop && confluent local services connect start
   ```
3. Check if the Salesforce plugin has been installed correctly and picked up by the plugin loader.
   ```bash
   curl -sS localhost:8083/connector-plugins | jq -c '.[] | select( .class | contains("Salesforce") )'
   ```

   This command should print the new Salesforce connector plugins available to the worker.
   ```bash
   {"class": "io.confluent.salesforce.SalesforcePlatformEventSourceConnector","type": "source","version": "1.1.0-preview"}
   {"class": "io.confluent.salesforce.SalesforcePushTopicSourceConnector","type": "source","version": "1.1.0-preview"}
   {"class": "io.confluent.salesforce.SalesforceSourceConnector","type": "source","version": "1.1.0-preview"}
   ```

<a id="salesforce-pushtopic-source-connector-quickstart-add-lead"></a>

# Add a lead to Salesforce

1. In the Salesforce user interface, find and click on the **App launcher**
   icon in the upper left of the page.
2. Find and start the [Leads](https://na85.lightning.force.com/lightning/o/Lead/home) application.
3. Click **New**, fill out the form, and then save it.

<a id="salesforce-pushtopic-source-connector-quickstart-config"></a>

# Configure the connector

This section includes the steps you’ll need to configure the PushTopic Source
connector.

1. Create a configuration file named
   `salesforce-pushtopic-lead-source-config.json` with the following contents.
   Ensure you enter the following:
   - Real username
   - Password
   - Security token
   - Consumer key
   - Consumer secret

   For more information on these and the other configuration properties, see
   [Salesforce PushTopic Source Connector Configuration Properties](salesforce_pushtopic_source_connector_config.md#salesforce-pushtopic-source-connector-config) .
   ```bash
   {
        "name": "lead-pushtopic",
        "config": {
            "connector.class" : "io.confluent.salesforce.SalesforcePushTopicSourceConnector",
            "key.converter" : "org.apache.kafka.connect.json.JsonConverter",
            "value.converter" : "org.apache.kafka.connect.json.JsonConverter",
            "tasks.max" : "1",
            "kafka.topic" : "sfdc-pushtopic-leads",
            "salesforce.object" : "Lead",
            "salesforce.push.topic.name" : "LeadsPushTopic",
            "salesforce.username" : "<Required>",
            "salesforce.password" : "<Required>",
            "salesforce.password.token" : "<Required>",
            "salesforce.consumer.key" : "<Required>",
            "salesforce.consumer.secret" : "<Required>",
            "salesforce.initial.start" : "all",
            "confluent.topic.bootstrap.servers": "localhost:9092",
            "confluent.topic.replication.factor": "1",
            "confluent.license": " Omit to enable trial mode "
        }
    }
   ```
2. Enter the Confluent CLI [confluent local services connect
   connector
   load](https://docs.confluent.io/confluent-cli/current/command-reference/local/services/connect/connector/confluent_local_services_connect_connector_load.html)
   command to start the Salesforce Source connector.
   ```bash
   confluent local load lead-pushtopic --config salesforce-pushtopic-lead-source-config.json
   ```

   Your output should resemble:
   ```bash
   {
      "name": "lead-pushtopic",
       "config": {
           "connector.class" : "io.confluent.salesforce.SalesforcePushTopicSourceConnector",
           "key.converter" : "org.apache.kafka.connect.json.JsonConverter",
           "value.converter" : "org.apache.kafka.connect.json.JsonConverter",
           "tasks.max" : "1",
           "kafka.topic" : "sfdc-pushtopic-leads",
           "salesforce.object" : "Lead",
           "salesforce.push.topic.name" : "LeadsPushTopic",
           "salesforce.username" : "<Required>",
           "salesforce.password" : "<Required>",
           "salesforce.password.token" : "<Required>",
           "salesforce.consumer.key" : "<Required>",
           "salesforce.consumer.secret" : "<Required>",
           "confluent.topic.bootstrap.servers": "localhost:9092",
           "confluent.topic.replication.factor": "1",
           "confluent.license": " Omit to enable trial mode "
       },
       "tasks": [
           ...
       ],
       "type": null
   }
   ```

   Note that the `tasks` field may include information about the one started task.

<a id="salesforce-pushtopic-source-connector-quickstart-view-leads"></a>

# View leads in Kafka topic

Navigate to your Confluent Platform installation directory and enter the following command to
install the latest version of the Salesforce connector.

```bash
kafka-avro-console-consumer --bootstrap-server kafka:9092 --from-beginning --topic sfdc-pushtopic-leads
```

<a id="salesforce-pushtopic-source-connector-quickstart-add-more-leads"></a>

# Add more leads to Salesforce

You can add and change leads as you need. The connector captures your changes
and writes them to the same topic.
