<!-- Source: https://docs.squirro.com/en/latest/technical/data-loading/connectors/one-click/microsoft-exchange.html -->
# Microsoft Exchange Connector

Squirro provides a 1-click connector for Microsoft Exchange. This connector allows the Project Creators to connect to a Microsoft Azure account and index the Microsoft Exchange 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/2470184465/2486567008.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2470184465/2486567008.png)

- Click on the _Microsoft_ _Exchange_ icon. Squirro will show a prompt asking you to authenticate your Microsoft Azure account. Click on the _Authenticate_ button there.

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

- Once you click on the _Authenticate_ button, you will be re-directed to the Sign-in screen hosted by Microsoft.

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

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

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

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

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

[![image5](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2470184465/2478113183.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2470184465/2478113183.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.

Messages and attachments from spam and trash folders are not fetched by default. To change that behaviour expand _the Advanced Options_ section and check the option to fetch data from spam and trash.

- 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 Microsoft Exchange data should be mapped to [Squirro items](../../../../../item-format/index).
- After clicking on _Save & Exit,_ you will see your source running. Sit back, relax & enjoy while we index your Microsoft Exchange data into Squirro.

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

## OAuth Configuration

### App Config

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

Note that the exact process on the Microsoft platform may change. If you notice big discrepancies between the current Microsoft website and the documentation page here, visit the [Squirro Support website](https://go.squirro.com/support) and submit a technical support request.

- Go to **Microsoft Azure Portal** here: [https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade), and click on the _Register an application_ button.

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

- On the next screen, choose the following options as shown in the screenshot below and then click on _Register_ button:

  - Name: Name of the app
  - Supported account types: “Accounts in any organizational directory (Any Entra ID directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)”
  - Redirect URI: This is the URL Microsoft will redirect the user to after successful authorization. This needs to be set to https://<your-server-url>/dataloader/exchange_plugin/pl/azure/authorized on your server.

    For example: https://squirro.example-company.com/dataloader/exchange_plugin/pl/azure/authorized.

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

- The next step is to add scopes to the app. To do that go to the _API permissions_ tab and click _Add a permission_ button.

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

- On the next screen click _Microsoft Graph_ button.

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

- Next go to the _Delegated permissions_ section.

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

- On the next screen add the following scopes:

  - `email`
  - `offline_access`
  - `User.Read`
  - `Mail.Read`.
- After adding scopes, confirm your choices by clicking _Add permissions_ button.

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

- In the next step go to the _Token configuration_ tab, click _Add optional claim_ button and add new claim:

  - Token type: “ID”
  - Claim: “email”.

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

- The final step is to create a Client secret key for your app. To do that go to the _Certificates & secrets_ tab, click _New client secret_ button and add a key:

  - Description: Name of your key (could be whatever you want)
  - Expires: Period of time after your secret key will expire (max period of time is 24 months).

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

### Apply for Production

Unverified apps will show a warning about unverified status during the user authorization process when the users connect their Squirro instance to their Microsoft account. To avoid that, you have to apply for Production status of the Microsoft Exchange app.

To start that process you first have to configure the **Branding**. This will require a logo icon, homepage URL, links to your terms of service and privacy policy. For more information go to the link: [https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-configure-publisher-domain](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-configure-publisher-domain).

## Squirro Configuration

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

- Go to the _Overview_ tab of the app and copy _Application (client) ID_.

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

- Next switch to the _Certificates & secrets_ tab and copy the value of your Client Secret key.

[![image16](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2470184465/2478113215.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2470184465/2478113215.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]
exchange_client_id = YOUR_ID
exchange_client_secret = YOUR_SECRET
```

- If the `[dataloader]` header is already present in this file, add the two 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
```
