# Integrating with SharePoint

[Prerequisites](#prerequisites)

[Azure Setup](#drivetrain-setup)\
&#x20;   [Step 1: Register an Application in Azure](#step-1-connect-your-onedrive-account)

[Drivetrain Setup](#drivetrain-setup)\
&#x20;  [Step 1: Connect your SharePoint Account](#step-1-connect-your-onedrive-account-1)\
&#x20;  [Step 2: Import File to Drivetrain](#step-2-import-file-to-drivetrain)

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Admin privileges in Azure Portal
* Admin privileges in Drivetrain
* The table you want to import should start from the first cell (A1) on the sheet
* None of the column headers should be empty
* There should only be one table per file
* Only .XLSX and .CSV files are supported

## Azure Setup <a href="#drivetrain-setup" id="drivetrain-setup"></a>

### **Step 1: Register an Application in Azure** <a href="#step-1-connect-your-onedrive-account" id="step-1-connect-your-onedrive-account"></a>

1. Login to [Azure Portal](https://portal.azure.com/#home) and search for "**App Registrations**" on the Azure home page.&#x20;

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FMCMWcd0ZwTiQfROjId6L%2Fimage.png?alt=media&#x26;token=e36eb8cf-5992-41ca-9c32-7e8c348a6ab7" alt=""><figcaption></figcaption></figure>

2. Click on **+ New registration**

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FTDns02YZ1qAZNPnmOdWN%2Fimage.png?alt=media&#x26;token=e50c5b04-e7e6-4a64-a311-31b7307f1afd" alt=""><figcaption></figcaption></figure>

3. Enter the name as "**Drivetrain SharePoint Integration**" and select **Accounts in this organizational directory only** as the supported account types and click **Register**

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FblZqvGR9ryEcoxgNEdfQ%2Fimage.png?alt=media&#x26;token=e196f711-f4f0-423e-a03c-bbdb130f68be" alt=""><figcaption></figcaption></figure>

4. On the next page, note down the **Application (client) ID** and **Directory (tenant) ID** in a secure document, these will be needed to configure SharePoint in Drivetrain.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FYosvAaAmR0gf9qYzPoPh%2Fimage.png?alt=media&#x26;token=f5b63427-5802-4dca-ad03-70fd38ec68fc" alt=""><figcaption></figcaption></figure>

5. On the left navigation menu, under manage click on "**Certificates & secrets**" and click on **+ New client secret**
6. Enter the description as "**Drivetrain SharePoint App**" and select maximum expiry date and click on **Add**
7. Note Value and Secret ID of the SharePoint application.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Flo3CxxF2dzIX2JELdB7U%2Fimage.png?alt=media&#x26;token=0d9c23a6-f0fc-41fb-b588-8cc6470e8c5b" alt=""><figcaption></figcaption></figure>

8. Navigate to **API Permissions** and click on **+ Add a Permission** and select **Microsoft Graph**
9. Under **Application Permissions,** search files and select **files.read** and **files.ReadWrite.all** permissions

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FIfZcbgqSVHvHOdm4rQbj%2Fimage.png?alt=media&#x26;token=020c15c3-91fe-4d24-868a-4044c95c3d24" alt=""><figcaption></figcaption></figure>

10. After selecting the Files permissions, search for **Sites** and select **Sites.FullControl.All, Sites.Read.All, Sites.ReadWrite.All** and click on Add permissions

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FPxPSwSNW44oT9ZHiw1Zs%2Fimage.png?alt=media&#x26;token=97c967c0-ec67-4825-b205-cbd3940334eb" alt=""><figcaption></figcaption></figure>

11. Once you save the permissions, click on Grant admin consent to apply the permissions.&#x20;

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2F7dnKEsFsw9Tc4Qz2Pf0v%2Fimage.png?alt=media&#x26;token=e2536b1d-0108-4abe-b8dd-6d35ca326552" alt=""><figcaption></figcaption></figure>

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FZKsNeNzD6HbpbuabcTTW%2Fimage.png?alt=media&#x26;token=445d40d1-7305-451d-b5f1-bc2e2456aab8" alt=""><figcaption></figcaption></figure>

12. Go to your SharePoint account, and go to the home page of your site which stores files to be pulled into Drivetrain and get the URL of that site. For eg: your sample URL will be yourcompany.sharepoint.com/sites/YourSiteName

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FQYRePQzTr5YWqa66lA9W%2Fimage.png?alt=media&#x26;token=d0900613-26a7-496a-8507-578570900502" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Please note that you have all the four details, as these will be needed to configure Sharepoint connector in Drivetrain:

1. Client ID
2. Client Secret  (Value of SharePoint Application, generated in step 7 of SharePoint Setup)
3. Tenant ID
4. Site URL
   {% endhint %}

## Drivetrain Setup <a href="#drivetrain-setup" id="drivetrain-setup"></a>

### **Step 1: Connect your SharePoint Account** <a href="#step-1-connect-your-onedrive-account" id="step-1-connect-your-onedrive-account"></a>

1. Click on **+** button on top left corner

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fmuppoc5viUPWwTc2Pmom%2Fod-1.webp?alt=media&#x26;token=538238c2-116c-495a-8329-37aee1176592" alt=""><figcaption></figcaption></figure>

2. Select the SharePoint connector under Spreadsheets category
3. Enter the details received in SharePoint Setup i.e. Client ID, Client Secret, Tenant ID and Site URL

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FvAnj67GzcHp4znwOUdOj%2Fimage.png?alt=media&#x26;token=b558349b-118f-45c7-b599-c9187ac854d8" alt=""><figcaption></figcaption></figure>

4. Once your SharePoint connector is authenticated, you will be redirected back to Drivetrain **Connected Integrations** page.
5. To add files, click on ‘**Add Data**’ and enter the URL of the file you want to import.

### **Step 2: Import File to Drivetrain** <a href="#step-2-import-file-to-drivetrain" id="step-2-import-file-to-drivetrain"></a>

1. Open SharePoint and navigate to the file you want to import
2. Copy the URL of the file which needs to be imported

{% hint style="info" %}
Please copy the URL using the address bar (see below image) and not using the copy link option available in OneDrive
{% endhint %}

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FHikuj7KMnzFjpg1FjMrl%2Fod-8.webp?alt=media&#x26;token=846d2aee-9572-40a1-ba94-1a5eabbfe0cf" alt=""><figcaption></figcaption></figure>

3. Paste your SharePoint File Link into the field provided and click **Add**

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2FZsVcZgduHSuzo47P6agA%2Fimage.png?alt=media&#x26;token=4c3a4daa-2625-462a-bc70-cacf81c9766f" alt=""><figcaption></figcaption></figure>

3. Please wait for some few mins until the sync is completed, the file you added will now show up in the list of tables on SharePoint connector

## FAQ <a href="#faq" id="faq"></a>

<details>

<summary>Can I load/refresh data from a SharePoint File?</summary>

Yes, you can connect your Sharepoint Account to Drivetrain. It'll be synced (i.e, refreshed) with the changes at predefined intervals. Alternatively, you can also [trigger a manual sync](https://docs.drivetrain.ai/getting-started/data/explore-your-datasets#resync). Refer to the above guide for more details

</details>
