Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onedrive-sharepoint-python-sdk-0.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file onedrive-sharepoint-python-sdk-0.0.1.tar.gz.

File metadata

File hashes

Hashes for onedrive-sharepoint-python-sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 39f030e6449f76ebe9ce71390dde4bcfdef4ac50100fb66bda28b2e8eb190566
MD5 a099951122b7371c04437be1b0f49782
BLAKE2b-256 4d847f7ec53fb01dc43ed1767ba41f8db7827e49aaaf99c062665e2baf854b2b

See more details on using hashes here.

File details

Details for the file onedrive_sharepoint_python_sdk-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for onedrive_sharepoint_python_sdk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b1a709f47cba3e28c65fdab8e68dded98e4748e00694de2d04c272f8cc7b53d
MD5 63c93609acd2c4c1cbaa1e6e2462d191
BLAKE2b-256 354a8440890ff62c45631ad4b3c067b8b2bca52fbdd3b5ce30aa1e415c598eb5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page