Connectors SharePoint / OneDrive

SharePoint / OneDrive

Text

The SharePoint / OneDrive connector is a text connector that fetches files from SharePoint sites or personal OneDrive using the Microsoft Graph API. It downloads file content and ingests claims via db.ingest_text().

How it works

SharePoint vs OneDrive

ModeParameterAPI path
SharePoint sitesite="contoso.sharepoint.com:/sites/team"/sites/{site}/drive/...
Personal OneDriveOmit site/me/drive/...

1 Register an Azure AD application

In the Azure Portal, register an application with the Files.Read.All delegated permission (or Sites.Read.All for SharePoint access).

2 Get an access token

Use the OAuth 2.0 authorization code flow or client credentials flow to obtain a Bearer token. For testing, use the Graph Explorer.

3 Install requests

$ pip install requests

4 Connect

conn = db.connect("sharepoint",
    token=os.environ["GRAPH_ACCESS_TOKEN"],
    site="contoso.sharepoint.com:/sites/engineering",
)
result = conn.run(db)
Parameter Required Default Description
token Yes Microsoft Graph API Bearer token
site No OneDrive SharePoint site identifier (e.g. contoso.sharepoint.com:/sites/team)
folder_path No Root Path within the drive to list files from
max_files No 50 Maximum number of files to process
extraction No heuristic Text extraction mode: heuristic or llm
save No False Encrypt and persist token

SharePoint site

conn = db.connect("sharepoint",
    token=os.environ["GRAPH_ACCESS_TOKEN"],
    site="contoso.sharepoint.com:/sites/engineering",
)
result = conn.run(db)
print(f"Ingested {result.claims_ingested} claims")

Personal OneDrive

conn = db.connect("sharepoint",
    token=os.environ["GRAPH_ACCESS_TOKEN"],
    max_files=100,
)
result = conn.run(db)

With folder path

conn = db.connect("sharepoint",
    token=os.environ["GRAPH_ACCESS_TOKEN"],
    site="contoso.sharepoint.com:/sites/docs",
    folder_path="/General/Reports",
    extraction="llm",
    save=True,
)
result = conn.run(db)

Related Connectors