<!-- Source: https://docs.squirro.com/en/latest/technical/data-loading/connectors/cloud/microsoft-one-drive.html -->
# Microsoft One Drive Connector

Profiles: Project Creator

This page describes how to set up and configure the Squirro 1-click connector for Microsoft One Drive.

This connector allows project creators to connect to a Microsoft One Drive account and select which data they’d like to index into Squirro.

Important: All document types including sheets are converted to PDF before ingesting into a Squirro project.

## Prerequisites

To use this connector, you’ll need the following:

- An existing Microsoft One Drive account with data.
- OAuth set up for 1-click connectors enabled within Squirro.

> **Note**
>
> 0Auth is set up by default on all cloud servers at [https://start.squirro.com](https://start.squirro.com/). For any other Squirro installation, ask your Squirro server admin to follow the steps in the [OAuth Configuration](dropbox.md#click-0auth) section below.

Squirro provides a 1-click connector for Microsoft OneDrive. This connector allows the Project Creators to connect to a Microsoft Azure account and index the Microsoft OneDrive data into Squirro.

## Set Up Connector

To connect Microsoft One Drive to Squirro, follow the steps below:

1. Open your Squirro project.
2. Navigate to the Setup space.
3. Click the Data tab. By default, you will be on the Data Sources page, as shown in the example screenshot below:

[![Add Data Sources](https://s3.amazonaws.com/download.squirro.net/docs/technical/data-loading/data-loader-example.png)](https://s3.amazonaws.com/download.squirro.net/docs/technical/data-loading/data-loader-example.png)

1. Click the orange plus sign (+) in the top-right corner of the page to add new data.
2. Click the Enterprise tab, then the Microsoft One Drive icon.

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

Once you’ve clicked _Authenticate_, you will be re-directed to the Sign-in screen hosted by Microsoft.

Note: 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/2478113223/2478113257.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2478113223/2478113257.png)

1. Sign in to your Microsoft account. Once you sign in you will be prompted to approve Microsoft OneDrive access.

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

1. Click Yes to approve. After approving, 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/2478113223/2470250213.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2478113223/2470250213.png)

1. Click Save for Squirro to automatically configure the mapping of item fields and labels, as well as any other required source configuration.

Both the media files (image, video, audio) and files from the trash are not fetched by default. To change that behavior expand _the Advanced Options_ section and select the appropriate option. Alternatively, you can define those settings manually by clicking _Next_ and going through the full source setup process.

> **Note**
>
> To index a specific folder, you must enter the path to the folder in the _Folder Path_ field WITHOUT the leading slash (`/`). For example, if you want to index the folder `/MyFolder`, you must enter `MyFolder` in the _Folder Path_ field.

Now, your data will begin indexing into Squirro.

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

## OAuth Configuration

To allow Squirro to connect to the Microsoft accounts of end users, you must register an OAuth2 app on the Microsoft portal.

### Microsoft Configuration

1. Open the **Microsoft Azure Portal** at [https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade).
2. Click Register an application.

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

1. Enter the following options as shown in the screenshot below:

- **Name**: Your name for the application.
- **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/onedrive_plugin/pl/azure/authorized` on your server.

Example: `https://squirro.example-company.com/dataloader/onedrive_plugin/pl/azure/authorized`

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

1. Click Register.
2. Navigate to the _API permissions_ tab and click Add a permission.

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

1. Click Microsoft Graph.

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

1. Navigate to the _Delegated permissions_ section.

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

1. Add the following:

- `email`
- `offline_access`
- `Files.Read.All`
- `GroupMember.Read.All`
- `Sites.Read.All`
- `User.ReadBasic.All`
- `User.Read`

`GroupMember.Read.All` is used to download files from the Group Drives. However, `GroupMember.Read.All` is a tenant-wide scope and requires admin consent to use.

Information on how to grant tenant-wide admin consent can be found at [https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/grant-admin-consent](https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/grant-admin-consent)

1. After adding scopes, confirm your choices by clicking Add permissions

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

1. Navigate to the _Token configuration_ tab, click Add optional claim and add a new claim as follows:

- Token type: `ID`
- Claim: `email`

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

1. To create a Client secret key for your app, navigate to the _Certificates & secrets_ tab, click New client secret and add a key:

- Description: `<your-key-name>` (can be anything you’d like)
- 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/2478113223/2478113323.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2478113223/2478113323.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 OneDrive 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, see [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’ll need to configure the Client ID and the Client Secret on your Squirro instance.

To do so, follow the steps below:

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

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

1. Go 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/2478113223/2478113335.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2478113223/2478113335.png)

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

```python
[dataloader]
onedrive_client_id = YOUR_ID
onedrive_client_secret = YOUR_SECRET
```

1. To enable org-wide access scopes used by your app also add the following line to the `[dataloader]` header:

```python
onedrive_org_scopes_enabled=true
```

Note: This requires tenant-wide admin consent described in the _App Config_ section.

1. 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.
2. Restart the frontend & datasource service to apply the settings:

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

You are now ready to connect your Squirro instance to Microsoft One Drive accounts!
