Tool

Read SharePoint Files and Site Pages

Load files or pages from a SharePoint site into LlamaIndex via Microsoft Entra ID app auth.

Works with microsoft sharepointmicrosoft graphmicrosoft entra id

73
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Access and extract data from your Microsoft SharePoint environment, including files from specified folders and content from site pages, for further processing or analysis.

Outcomes

What it gets done

01

Load files from SharePoint folders recursively.

02

Extract content from SharePoint site pages.

03

Authenticate securely using Microsoft Entra ID.

04

Support for Sites.Selected permission for granular access.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-microsoft-sharepoint | bash

Overview

Microsoft SharePoint Reader

A LlamaIndex reader that loads SharePoint files or Site Pages via an Entra ID app-registered identity with configurable Graph permissions. Use when Entra ID app registration and Graph permissions with admin consent are already in place for the target SharePoint site(s).

What it does

The Microsoft SharePoint Reader loads files from a folder in a SharePoint site, or SharePoint Site Pages, into LlamaIndex documents, and supports traversing recursively through sub-folders. Authentication is app-based through Microsoft Entra ID (formerly Azure AD): an App Registration is created in Entra ID and granted Microsoft Graph application permissions - either Sites.Read.All for access to every site in the tenant, or the narrower Sites.Selected to grant access only to specific chosen sites - plus Files.Read.All and BrowserSiteLists.Read.All, all requiring admin consent.

SharePointReader is initialized with a client_id, client_secret, and tenant_id from the registered app, and load_data takes a sharepoint_site_name, a sharepoint_folder_path, and a recursive flag to control sub-folder traversal. When using the narrower Sites.Selected permission, the reader can instead be pointed at a specific site via sharepoint_host_name and sharepoint_relative_url rather than a site name. The reader can also load SharePoint Site Pages instead of files by setting sharepoint_type to SharePointType.PAGE - either loading every page via load_data(), or a specific page by setting sharepoint_file_id before calling load_data().

When to use - and when NOT to

Use it when you need to bring files or pages from a specific SharePoint site or folder into LlamaIndex, recursively if needed, using an app-registered service identity rather than a user's personal credentials. Choose Sites.Selected over Sites.Read.All when you want to scope the app's access to specific sites rather than every site in the tenant - Sites.Selected requires the app to also be explicitly granted access to those sites via the SharePoint admin center. Do not use it without completing the Entra ID app registration and granting the required Graph permissions with admin consent first - none of the loading functions will work without that authorization already in place.

Capabilities

Loads files from a SharePoint folder (optionally recursive) into documents, or loads SharePoint Site Pages (all pages or one specific page by ID) instead of files, authenticated via a registered Entra ID app with either tenant-wide or site-scoped Graph permissions.

How to install

pip install llama-index-readers-microsoft-sharepoint

Requires an Entra ID App Registration with Microsoft Graph application permissions (Sites.Read.All or Sites.Selected, plus Files.Read.All and BrowserSiteLists.Read.All, all with admin consent), and the app's client_id, client_secret, and tenant_id.

Who it's for

Developers who need to bring SharePoint files or site pages into a LlamaIndex pipeline using an app-level service identity, whether across an entire tenant or scoped to specific sites.

Source README

Microsoft SharePoint Reader

pip install llama-index-readers-microsoft-sharepoint

The loader loads the files from a folder in SharePoint site or SharePoint Site Pages.

It also supports traversing recursively through the sub-folders.

Prerequisites

App Authentication using Microsoft Entra ID (formerly Azure AD)

  1. You need to create an App Registration in Microsoft Entra ID. Refer here
  2. API Permissions for the created app:
    • Microsoft Graph → Application Permissions → Sites.Read.All (Grant Admin Consent)
      (Allows access to all sites in the tenant)
    • OR
      Microsoft Graph → Application Permissions → Sites.Selected (Grant Admin Consent)
      (Allows access only to specific sites you select and grant permissions for)
    • Microsoft Graph → Application Permissions → Files.Read.All (Grant Admin Consent)
    • Microsoft Graph → Application Permissions → BrowserSiteLists.Read.All (Grant Admin Consent)

Note:
If you use Sites.Selected, you must grant your app access to the specific SharePoint site(s) via the SharePoint admin center.
See Grant access to a specific site for details.

More info on Microsoft Graph APIs - Refer here

Usage

To use this loader client_id, client_secret and tenant_id of the registered app in Microsoft Azure Portal is required.

Loading Files from SharePoint Drive

This loader loads the files present in a specific folder in SharePoint.

If the files are present in the Test folder in SharePoint Site under root directory, then the input for the loader for file_path is Test

from llama_index.readers.microsoft_sharepoint import SharePointReader

loader = SharePointReader(
    client_id="<Client ID of the app>",
    client_secret="<Client Secret of the app>",
    tenant_id="<Tenant ID of the Microsoft Azure Directory>",
)

documents = loader.load_data(
    sharepoint_site_name="<Sharepoint Site Name>",
    sharepoint_folder_path="<Folder Path>",
    recursive=True,
)

Using Sites.Selected Permission

If you have only been granted access to a specific site (using Sites.Selected), you can use the site host name and relative URL instead of the site name:

from llama_index.readers.microsoft_sharepoint import SharePointReader

loader = SharePointReader(
    client_id="<Client ID of the app>",
    client_secret="<Client Secret of the app>",
    tenant_id="<Tenant ID of the Microsoft Azure Directory>",
    sharepoint_host_name="contoso.sharepoint.com",
    sharepoint_relative_url="sites/YourSiteName",
)

documents = loader.load_data(
    sharepoint_folder_path="<Folder Path>",
    recursive=True,
)

Loading SharePoint Site Pages

You can also load SharePoint Site Pages as documents by setting sharepoint_type to PAGE:

from llama_index.readers.microsoft_sharepoint import (
    SharePointReader,
    SharePointType,
)

loader = SharePointReader(
    client_id="<Client ID of the app>",
    client_secret="<Client Secret of the app>",
    tenant_id="<Tenant ID of the Microsoft Azure Directory>",
    sharepoint_site_name="<Sharepoint Site Name>",
    sharepoint_host_name="<your-tenant>.sharepoint.com",
    sharepoint_relative_url="/sites/<YourSite>",
    sharepoint_type=SharePointType.PAGE,
)

### Load all pages
documents = loader.load_data()

### Or load a specific page by ID
loader.sharepoint_file_id = "<page_id>"
documents = loader.load_data()

Filtering Pages with Callbacks

You can filter which pages to process using the process_document_callback:

def page_filter(page_name: str) -> bool:
    # Only process pages that don't start with "Draft"
    return not

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.