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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onedrive-sharepoint-python-sdk-0.0.2.tar.gz | 7.2 kB | Without provenance | Details for onedrive-sharepoint-python-sdk-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onedrive_sharepoint_python_sdk-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for onedrive_sharepoint_python_sdk-0.0.2-py3-none-any.whl |
Total release size: 15.2 kB
Security for onedrive-sharepoint-python-sdk 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.