Skip to main content

OneDriveClient README

Overview

OneDriveClient is a Python class that provides a simple interface for interacting with Microsoft OneDrive using the Microsoft Graph API. This class allows you to connect to OneDrive, upload and download files, move or rename files, and manage folders and files within a OneDrive account.

Installation

To use the OneDriveClient class, you need to install:

python3 -m pip install shipyard-microsoft-onedrive

Usage

Initialization

Create an instance of the OneDriveClient class by providing your client ID, client secret, tenant ID, and optionally, a user email.

from OneDriveClient import OneDriveClient

client = OneDriveClient(
    client_id='your_client_id',
    client_secret='your_client_secret',
    tenant='your_tenant_id',
    user_email='user_email@example.com'
)

Connecting to OneDrive

Connect to OneDrive using the connect method. This method will acquire an access token using client credentials.

client.connect()

Getting User and Drive ID

To obtain the user and drive ID associated with the credentials, run the following:

user_id = client.get_user_id()
drive_id = client.get_drive_id(user_id)

Common Methods

Uploading Files

Upload a file to OneDrive using the upload method. Specify the local file path, drive ID, and the path in OneDrive where the file should be uploaded.

client.upload(file_path='path/to/local/file', drive_path='path/in/onedrive', drive_id=drive_id)
Downloading Files

Download a file from OneDrive using the download method. Provide the local file path to save the file, the path in OneDrive, and the drive ID.

client.download(file_path='path/to/save/file', drive_path='path/in/onedrive', drive_id=drive_id)
Moving/Renaming Files in OneDrive

Move or rename a file in OneDrive using the move method. Specify the source name, source directory, target name, target directory, and drive ID.

client.move(src_name='source_file_name', src_dir='source_directory', target_name='new_file_name', target_dir='target_directory', drive_id=drive_id)
Removing Files in OneDrive

Remove a file from OneDrive using the remove method. Provide the path in OneDrive and the drive ID.

client.remove(drive_path='path/in/onedrive', drive_id=drive_id)

Metadata

Release files for shipyard-microsoft-onedrive 0.2.0

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

Source distribution (sdist)

Source distribution for shipyard-microsoft-onedrive 0.2.0
File Size Uploaded
shipyard_microsoft_onedrive-0.2.0.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shipyard-microsoft-onedrive 0.2.0
File Interpreter ABI Platform
shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / shipyard_microsoft_onedrive-0.2.0.tar.gz

Download URL shipyard_microsoft_onedrive-0.2.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e53ce3d4eb2b83ce705eb76031b7897d3ef64a428f3e93e3f94beec5cdbfb922
BLAKE2b-256 checksum
How to use checksums
9457ac08f6963122885dfe2fab31a5bce798089a71c2e3f528f7822bbd76d9e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.16 Darwin/22.5.0

Release files / shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl

Download URL shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dfb26e458bdcf0034379835f6eb47a23d559e87bf2f16e5eb9d2a0c244fbd03
BLAKE2b-256 checksum
How to use checksums
efabcf0c4ad0776265fed43709cb86302a9085b8c5a740c5037e45e32bafa287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.16 Darwin/22.5.0
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