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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shipyard_microsoft_onedrive-0.2.0.tar.gz
.
File metadata
- Download URL: shipyard_microsoft_onedrive-0.2.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.9.16 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e53ce3d4eb2b83ce705eb76031b7897d3ef64a428f3e93e3f94beec5cdbfb922 |
|
MD5 | cba3e3cb91bc2f40de2a1d1dd3d093a4 |
|
BLAKE2b-256 | 9457ac08f6963122885dfe2fab31a5bce798089a71c2e3f528f7822bbd76d9e3 |
File details
Details for the file shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: shipyard_microsoft_onedrive-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.9.16 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dfb26e458bdcf0034379835f6eb47a23d559e87bf2f16e5eb9d2a0c244fbd03 |
|
MD5 | acbf5948672e31bf6ec1e150bbd833c8 |
|
BLAKE2b-256 | efabcf0c4ad0776265fed43709cb86302a9085b8c5a740c5037e45e32bafa287 |