# SharePoint REST API V2.0

---

Remote item name: **SharePoint2**

It is often called “V2” is Microsoft's way of exposing SharePoint Online functionality through endpoints that align closely with Microsoft Graph. V2 allows you to make calls directly to SharePoint using Graph-like URLs. This approach uses SharePoint-scoped access tokens and avoids routing through the Graph proxy when possible, leading to potentially better performance and simpler security contexts in SharePoint-integrated apps.

More info: [SharePoint REST operations via the Microsoft Graph REST API Link](https://learn.microsoft.com/en-us/sharepoint/dev/apis/sharepoint-rest-graph)

🛑 Important: This API only works if you configure **Shared Link** for SharePoint2 [VFS](VFS.md) settings.

---

**🛑 Proxy Configuration:** If your environment uses a Proxy or a strict Firewall, you must authorize outbound traffic to the following Microsoft endpoints:\
• **login.microsoftonline.com**\
• **\<yourtenant>.sharepoint.com** — for accessing SharePoint site collections

---

## App Registration for SharePoint REST API Access

Open the **Microsoft Entra Admin Center** (formerly Azure AD) to manage your app registration: [Microsoft Entra Admin Center Link](https://entra.microsoft.com/)

Navigation: Go to **App registrations**.

![New registration](SharePoint-Integration/new_registration.png)

In the Redirect URI section, for Platform configuration, select **Web**. The Redirect URL must end with **register_microsoft_graph_api/**. Examples:

```
    http://localhost:9090/register_microsoft_graph_api/
    or
    https://your.crushftp.domain.com/register_microsoft_graph_api/
```

## 1. Permission Type: Application Permission

Application permissions are used when an application runs without a signed-in user, such as in server-to-server connections.

**App Registration SharePoint Scopes**:

![App registration sharepoint permissions](SharePoint-REST-service-API/app_registration_sharepoint-permissions.png)

Choose one of the Application access level for SharePoint integration:

**a.) SharePoint.AllSites.FullControl**: Grants an application full control over all site collections in SharePoint Online across the entire tenant. This is the highest level of SharePoint permission available for applications and enables full administrative access to both content and site settings.

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Application Permission**. Search for AllSites and check the flag **AllSites.FullControl**.

---

**b.) SharePoint.AllSites.Manage**: Grants an app manage-level access to all site collections in SharePoint Online. This includes the ability to read and write content, as well as manage lists and libraries, but not full administrative control (e.g., cannot manage site permissions or site settings).

This permission allows the app to:\
• Access all SharePoint sites in the tenant.\
• Create, read, update, and delete\
• Files and folders\
• Lists and list items\
• Libraries and site content structures

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Application Permission**. Search for AllSites and check the flag **AllSites.Manage**.

---

**c.) SharePoint.Sites.Selected**: The **Sites.Selected** permission allows an app to access only the specific SharePoint sites you explicitly authorize. **⚠️ Important:** The application must first be registered in Azure AD with the Sites.Selected application permission. More information is available at the following link: [Managing SharePoint Site Access for Applications Using Sites.Selected Permission](CrushTaskExample19.md).

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Application Permission**. Search for Sites and check the flag **Sites.Selected**.

---

## 1.1 Configure Application Authentication:

Fetch the application credentials from your App Registration to enable the integration. You may use either a **Client Secret** or a **Certificate-based authentication** (Recommended for Production).

## 1.1.1 SharePoint2 VFS item configuration: Application Permission - Certificate Based:

**Certificates**: See at App Registration -> Certificates & secrets

![Azure app registrations certificates](SharePoint-Integration/azure_app_registrations_certificates.png)

![Vfs sharepoint 2 v2 cert based](SharePoint-REST-API-V2.0/vfs_sharepoint2_v2_cert_based.png)

Select the **Application Permission (cert based)** radio button, then click **Application Permission cert based** button.

![App permission cert based form](SharePoint-Integration/app_permission_cert_based_form.png)

Enter the **Client ID** (See at App Registration -> Overview -> Application (client) ID).

**Thumbprint**: (See at App Registration -> Manage -> Certificates & secrets) Select **Certificates**.\
**Private Key**: This is your application's unique digital credential, which pairs with the public certificate you uploaded in Azure Portal. It allows the system to securely access SharePoint without a password. We accept the **PKCS#8** key text format (often starting with -----BEGIN PRIVATE KEY-----).

**Tenant ID** (See at App Registration -> Overview -> Directory (tenant) ID), then click OK. This will automatically configure the **username** and **password** in the [VFS](VFS.md) item settings. After that, click the **OK** button and proceed with the SharePoint site-specific configuration. See under the [3.Sharepoint-specific settings](SharePoint-REST-API-V2.0.md#section-SharePoint+REST+API+V2.0-3.SharepointSpecificSettingsSharedLink)

## 1.2.1 SharePoint VFS item configuration: Application Permission - Client Secret Based:

**Client Secret**:

Go to Certificates & secrets, and generate a new client secret by clicking on New client secret. ⚠️ Ensure you copy over the **value** immediately!

![New secret](SharePoint-Integration/new_secret.png)

![Secret value](SharePoint-Integration/secret_value.png)

![Vfs sharepoint 2 v2 client secret](SharePoint-REST-API-V2.0/vfs_sharepoint2_v2_client_secret.png)

Select the **Application Permission** radio button, then click **Application Permission** button.\
![App permission client secret form](SharePoint-Integration/app_permission_client_secret_form.png)

Enter the **Client ID** (See at App Registration -> Overview -> Application (client) ID),**Client Secret** (See at App Registration -> Manage -> Certificates & secrets). ⚠️ Make sure to copy the **value** field, not the ID.\
**Tenant ID** (See at App Registration -> Overview -> Directory (tenant) ID), then click OK. This will automatically configure the **username** and **password** in the [VFS](VFS.md) item settings. After that, click the **OK** button and proceed with the SharePoint site-specific configuration.

**Tennant:** See at App Registration -> Overview -> Directory (tenant) ID. Based on the App Registration Account type, it can be an ID, common, or consumer.

Provide the SharePoint-specific settings. See under the [3.Sharepoint-specific settings](SharePoint-REST-API-V2.0.md#section-SharePoint+REST+API+V2.0-3.SharepointSpecificSettingsSharedLink)

## 2. Permission Type: Delegated Permission:

Delegated permissions are used when an application makes API calls as the signed-in user. The app is delegated the user’s permissions and can only access resources that the user is authorized to access.

**Redirect URL**: The Redirect URL must end with **register_microsoft_graph_api/**. Examples:

```
    http://localhost:9090/register_microsoft_graph_api/
    or
    https://your.crushftp.domain.com/register_microsoft_graph_api/
```

![App registration redirect url](SharePoint-REST-service-API/app_registration_redirect_url.png)

**App Registration SharePoint Scopes**:

Choose one of the **Delegated** access level for SharePoint integration:

---

**a.) SharePoint.AllSites.FullControl**: Grants an application full control over all site collections in SharePoint Online across the entire tenant. This is the highest level of SharePoint permission available for applications and enables full administrative access to both content and site settings.

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Delegated Permission**. Search for AllSites and check the flag **AllSites.FullControl**.

---

**b.) SharePoint.AllSites.Manage**: Grants an app manage-level access to all site collections in SharePoint Online. This includes the ability to read and write content, as well as manage lists and libraries, but not full administrative control (e.g., cannot manage site permissions or site settings).

This permission allows the app to:\
• Access all SharePoint sites in the tenant.\
• Create, read, update, and delete\
• Files and folders\
• Lists and list items\
• Libraries and site content structures

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Delegated Permission**. Search for AllSites and check the flag **AllSites.Manage**.

---

**c.) SharePoint.Sites.Selected**: The **Sites.Selected** permission allows an app to access only the specific SharePoint sites you explicitly authorize. **⚠️ Important:** The application must first be registered in Azure AD with the Sites.Selected application permission. More information is available at the following link: [Managing SharePoint Site Access for Applications Using Sites.Selected Permission](CrushTaskExample19.md).

Navigate to **API Permissions**. Click on **Add a permission** button. Select **SharePoint**. Then select **Delegated Permission**. Search for Sites and check the flag **Sites.Selected**.

![App permission sharepoint site selected](CrushTaskExample19/app_permission_sharepoint_site_selected.png)

---

⚠️ Warning **Admin consent** for the newly added permission.

![App permission admin consent](SharePoint-Integration/app_permission_admin_consent.png)

**Secret key**: A new client secret must be created. Go to **Certificates & secrets**, and generate a new client secret by clicking on **New client secret**. ⚠️ Ensure you copy over the **value** immediately!

![New secret](SharePoint-Integration/new_secret.png)

![Secret value](SharePoint-Integration/secret_value.png)

## 2.1 SharePoint2 remote item settings (Delegated Permission):

**⚠️ Warning**: To obtain the **Refresh Token**, the CrushFTP WebInterface’s host and port must match the **Redirect URL** specified in the **Azure App Registration**. In our example, it was: http<!-- -->://localhost:9090 or https<!-- -->://your.crushftp.domain.com/

Click on **Get Refresh Token**.

Enter the **Client ID** (See at App Registration -> Overview -> Application (client) ID), **Client Secret** (See at App Registration -> Manage -> Certificates & secrets) make sure to copy the **value** field, not the ID, and **Tenant ID** (See at App Registration -> Overview -> Directory (tenant) ID).

Click the **OK** button and proceed with the authentication and authorization process.

**⚠️ Warning**: Be sure to sign in with the Microsoft Account that has the necessary permissions, as configured in the Azure App Registration mentioned above.\
This will automatically configure the username and password in the VFS item settings. After that, proceed with the SharePoint site-specific configuration.

Tennant: See at App Registration -> Overview -> Directory (tenant) ID. Based on the App Registration Account type it can be an ID, common, or consumer.

Provide the SharePoint-specific settings. See under the [Sharepoint-specific settings](SharePoint-REST-API-V2.0.md#section-SharePoint+REST+API+V2.0-3.SharepointSpecificSettingsSharedLink)

![Sharepoint 2 v2 refresh token vfs item](SharePoint-REST-API-V2.0/sharepoint2_v2_refresh_token_vfs_item.png)

---

## 3.Sharepoint-specific settings - Shared Link:

![Sharepoint shared link vfs settings](SharePoint-Microsoft-Graph-REST-API/sharepoint_shared_link_vfs_settings.png)

## 3.1 Shared Link of Document Library:

In your web browser, open your SharePoint site and navigate to the **Document Library** (See [SharePoint: Documents and Libraries Description Link](https://support.microsoft.com/en-us/office/what-is-a-document-library-3b5976dd-65cf-4c9e-bf5a-713c10ca2872)) Copy the complete URL from your browser's address bar.\
![Shared link document library](SharePoint-Microsoft-Graph-REST-API/shared_link_document_library.png)\
It will look similar to this:

```
https://your.sharepoint.com/sites/your_site/Shared%20Documents/Forms/AllItems.aspx
```

Return to the VFS settings and paste the URL into the **Shared Link** input field.

## 3.2 Link to Specific Folder:

![Shared link specific folder](SharePoint-Microsoft-Graph-REST-API/shared_link_specific_folder.png)\
In your web browser, open your SharePoint site and navigate to the **Document Library**, and find the specific folder you want to link to. Right-click on the folder. Select **Copy link** from the context menu that appears.\
It will look similar to this:

```
https://your.sharepoint.com/:f:/s/your_site/Evxo0AjlwiZAnajkk56_AC0BDxGQDy7bgNu8F7HHgVMKtQ?e=BgvJps
```

Return to the VFS settings and paste the URL into the **Shared Link** input field.

---

Back to [SharePoint Integration](SharePoint-Integration.md)

---
