sda.api.graph_client#
MS Graph API client for SharePoint file access.
Attributes#
Classes#
Client for interacting with SharePoint via MS Graph API. |
Functions#
|
Download from |
Module Contents#
- sda.api.graph_client.GRAPH_BASE = 'https://graph.microsoft.com/v1.0'#
- sda.api.graph_client.download_presigned_graph_url(url, destination, *, timeout=300.0, max_attempts=3)#
Download from
@microsoft.graph.downloadUrlwithout an Authorization header.The URL is already authenticated (temporary SAS). Uses HTTP/1.1 only, a normal User-Agent, and limited retries for transient connection resets.
- class sda.api.graph_client.GraphClient(tenant_id, client_id, client_secret)#
Client for interacting with SharePoint via MS Graph API.
- download_file(site_id, drive_id, item_path, destination)#
Download a file from SharePoint and save to destination.
- Parameters:
- Returns:
The
destinationpath after writing.- Return type:
Path
Notes
Uses the
@microsoft.graph.downloadUrlpre-signed URL from the item metadata rather than the/contentredirect endpoint. The/contentendpoint issues a 302 to Azure Blob Storage; following it with anAuthorizationheader causes aWinError 10054connection reset because Blob Storage uses SAS-based auth, not Bearer tokens.
- list_folder_children(site_id, drive_id, folder_path, filename_filter='*')#
List files inside a SharePoint drive folder, following pagination.
- Parameters:
site_id (
str) – SharePoint site ID.drive_id (
str) – Drive ID within the site.folder_path (
str) – Path to the folder within the drive root (e.g."Gif/T297"). Use""or"/"for the drive root.filename_filter (
str, optional) – Glob pattern to filter file names, by default"*"(all files). Example:"*.xls*"to matchxlsx/xlsm/xls.
- Returns:
List of dicts with keys
"name"and"download_url"for each matching file."download_url"is the pre-signed Azure Blob Storage URL (@microsoft.graph.downloadUrl).- Return type:
list[dict]