Skip to main content

OneDrive and SharePoint Python SDK

A Python SDK for accessing files in OneDrive & SharePoint using the Microsoft Graph API.

Functionality includes:

  • Upload and download files
  • List files and folders in directories
  • List the SharePoint sites that you follow
  • Search for a SharePoint site and it's drives

Installation

Requires Python 3.7+

pip install onedrive-sharepoint-python-sdk

Examples

See the examples folder for more.

OneDrive

from msdrive import OneDrive

drive = OneDrive("access_token_here")

drive.download_item(item_path="/Documents/my-data.csv", file_path="my-data.csv")
drive.upload_item(item_path="/Documents/new-or-existing-file.csv", file_path="new-or-existing-file.csv")

SharePoint

from msdrive import SharePoint

drive = SharePoint("access_token_here")

drive.download_item(drive_id="b!...", item_path="/General/shared-data.csv", file_path="shared-data.csv")
drive.upload_item(drive_id="b!...", item_path="/General/new-or-existing-file.csv", file_path="new-or-existing-file.csv")

Authentication

The SDK does not handle authentication, it presumes you already have a Microsoft access token which you pass into the constructor (see auth example).

Use a library like MSAL or Azure Identity to handle this.

Local Development

pip install -e .[tests]
pytest # run unit tests

Deployment

Bump the version in pyproject.toml and src/msdrive/__init__.py and then run the Upload Python Package pipeline.

Metadata

Release files for onedrive-sharepoint-python-sdk 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onedrive-sharepoint-python-sdk 0.0.2
File Size Uploaded
onedrive-sharepoint-python-sdk-0.0.2.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for onedrive-sharepoint-python-sdk 0.0.2
File Interpreter ABI Platform
onedrive_sharepoint_python_sdk-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / onedrive-sharepoint-python-sdk-0.0.2.tar.gz

Download URL onedrive-sharepoint-python-sdk-0.0.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d5eefb901b8aa433aa37d9740a87086021b7205d1fcf594d3ee8088adcf75120
BLAKE2b-256 checksum
How to use checksums
db2ab6813f1976a9227371eeeed661a34c9868b57f5bbaf0be2402114ff6936a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / onedrive_sharepoint_python_sdk-0.0.2-py3-none-any.whl

Download URL onedrive_sharepoint_python_sdk-0.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3939d7914e7711b09c9440e4e914d6ccc45843b63dd93bcfd237df15547f598a
BLAKE2b-256 checksum
How to use checksums
b9b5d6631aab32fafdc62e5dbf99a6a1f9e951b309e2828e2dfd20e5817cd2fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page