Skip to main content

A local client for working with files in Microsoft OneDrive

Project description

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)

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

shipyard_microsoft_onedrive-0.2.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file shipyard_microsoft_onedrive-0.2.0.tar.gz.

File metadata

File hashes

Hashes for shipyard_microsoft_onedrive-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e53ce3d4eb2b83ce705eb76031b7897d3ef64a428f3e93e3f94beec5cdbfb922
MD5 cba3e3cb91bc2f40de2a1d1dd3d093a4
BLAKE2b-256 9457ac08f6963122885dfe2fab31a5bce798089a71c2e3f528f7822bbd76d9e3

See more details on using hashes here.

File details

Details for the file shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dfb26e458bdcf0034379835f6eb47a23d559e87bf2f16e5eb9d2a0c244fbd03
MD5 acbf5948672e31bf6ec1e150bbd833c8
BLAKE2b-256 efabcf0c4ad0776265fed43709cb86302a9085b8c5a740c5037e45e32bafa287

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