<!-- Source: https://docs.squirro.com/en/latest/technical/data-loading/connectors/one-click/salesforce-service.html -->
# Salesforce Service Cloud Connector

Squirro provides a 1-click connector for Salesforce Service Cloud. This connector allows the Project Creators to connect to a Salesforce account and index the Salesforce Service Cloud data into Squirro.

## Set Up Connector

Usage assumes that the OAuth setup for the 1-click connectors has already been done on the server. This is by default available on all of our cloud servers at [https://start.squirro.com](https://start.squirro.com/). For any other Squirro installation, please ask your Squirro server admin to follow the steps in the _OAuth Configuration_ section below.

- Head over to the _Enterprise_ tab on the _Data_ screen as shown in the screenshot below.

[![image1](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107679.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107679.png)

- Click on the _Salesforce Service Cloud_ icon. Squirro will show a prompt asking you to authenticate your Salesforce account. Click on the _Authenticate_ button there.

[![image2](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173251.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173251.png)

- Once you click on the _Authenticate_ button, you will be prompted to choose the type of your Salesforce instance.

[![image3](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107692.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107692.png)

- After you choose the type of your Salesforce instance and click the _Select_ button, you will be re-directed to the Sign-in screen hosted by Salesforce.

Squirro will never ask you for your Salesforce password. This is requested by Salesforce itself.

[![image4](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107698.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107698.png)

- Once you sign-in you will be prompted to approve Salesforce Service Cloud scopes. This screen is presented to you by Salesforce asking you to provide consent for your Salesforce Service Cloud data to Squirro.

[![image5](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173257.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173257.png)

- After approving scopes you will be brought back to Squirro’s source configuration screen. This screen shows which Salesforce account Squirro has connected to.

[![image6](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173263.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173263.png)

- Now, you can click _Save & Exit_ for Squirro to automatically configure the mapping of item fields and labels, as well as any other required source configuration.

Squirro fetches only Tasks and Events by default. To download other Salesforce’s objects as well, expand _Advanced Options_ section and check appropriate options. Also note that archived or deleted items and media files are not fetched. You can also change that behaviour in _the Advanced Options_ section.

- Alternatively you can define those settings manually by clicking _Next_ and going through the whole source setup process. This allows you the full flexibility of how the Salesforce Service Cloud data should be mapped to Squirro items.
- After clicking on _Save & Exit,_ you will see your source running. Sit back, relax & enjoy while we index your Salesforce Service Cloud data into Squirro.

[![image7](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173269.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173269.png)

If you receive an error informing you that “API is disabled for this user”, please ask your Salesforce server admin to follow the steps described in the _Enable API Permission_ section below.

## OAuth Configuration

### App Config

You will need to register an OAuth2 app on a Salesforce instance to allow Squirro to connect to the Salesforce accounts of end users. Please follow the steps below to do so.

Steps below are described using Salesforce Lightning version of the page. Also note that the exact process on the Salesforce platform may change. If you notice big discrepancies between the current Salesforce website and the documentation page here, visit the [Squirro Support website](https://go.squirro.com/support) and submit a technical support request.

- Go to the settings of a Salesforce instance. You can do that by clicking on the _Settings_ icon in the right top corner of the screen and then choosing _Setup_ option.

[![image8](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107722.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107722.png)

- On the next screen, go to the _App Manager_ tab in the _Apps_ section and click the _New Connected App_ button.

[![image9](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107728.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107728.png)

- The next step is to provide settings of your app. Choose the following options as shown in the screenshot below and then click on the _Save_ button:

  - Connected App Name: Name of the app
  - API Name: Unique identifier of the app
  - Contact Email: Email to contact
  - Enable OAuth Settings: checked
  - Callback URL: This is the URL Salesforce will redirect the user to after successful authorization. This needs to be set to https://<your-server-url>/dataloader/servicecloud_plugin/pl/salesforce/authorized on your server.

    For example: https://squirro.example-company.com/dataloader/servicecloud_plugin/pl/salesforce/authorized
  - Selected OAuth Scopes:

    - “Access and manage your data (api)”
    - “Perform requests on your behalf at any time (refresh_token, offline_access)”.

[![image10](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173277.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488173277.png)

- Once you save your settings you will receive information that Salesforce needs a few minutes to apply changes on the server. Click _Continue_ button to approve settings.

[![image11](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107740.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107740.png)

### Enable API Permission

- In order to allow users to fetch their data from Salesforce instance the API permission has to be enabled. To do that, go to the _Profiles_ tab in the _Users_ section.

[![image12](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107746.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107746.png)

- Click _Edit_ on the specific profile users who are going to fetch data belongs to.
- Make sure that _API Enabled_ option is checked.

[![image13](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107752.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107752.png)

- Save settings.

## Squirro Configuration

After having created the OAuth2 app on the Salesforce instance, you need to configure the Client ID and the Client Secret on your Squirro instance.

- Go to the _App Manager_ tab in the _Apps_ section, click the arrow button next to your app and then choose _View_ option.

[![image14](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107758.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107758.png)

- Copy the _Consumer Key_ and _Consumer Secret_.

[![image15](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107764.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2488107659/2488107764.png)

This configuration will soon be possible from the user interface.

- Edit `/etc/squirro/common.ini` on your Squirro cluster and add the following lines:

```python
[dataloader]
servicecloud_client_id = YOUR_ID
servicecloud_client_secret = YOUR_SECRET
```

- If the `[dataloader]` header is already present in this file, add the lines to the existing section. The section header can not appear more than once in the configuration file.
- Restart the frontend & datasource service to apply the settings:

```python
sudo systemctl restart sqfrontendd
sudo systemctl restart sqdatasourced
```
