Perform simple tasks on OneDrive through the Graph API.
Project description
Graph-OneDrive
Interact with Microsoft's OneDrive service using the Graph API.
The Graph-OneDrive package facilitates the creation of OneDrive class instances which are objects that you can use to interact with OneDrive sessions. Thus multiple OneDrives can be connected to in parallel.
Functions include:
- listing directories
- moving, copying, and renaming files and folders
- uploading and asynchronously downloading files
- getting file and drive metadata including usage
- getting links to files and creating sharing links
Azure app requirement
For the package to connect to the Graph API, you need to have an app registered in the Microsoft Azure Portal. The documentation provides basic guidance on how to register an app.
Note that some Microsoft work and school accounts will not allow apps to connect with them without admin consent.
Installation
The package currently requires Python 3.7 or greater.
Install and update using pip which will use the releases hosted on PyPI. Further options in the docs.
pip install graph-onedrive
Documentation
Documentation and examples are provided on GitHub in the docs folder.
A simple example
Run this command in the terminal after installation which will create a config file in the current working directory.
graph-onedrive --configure --authenticate -f "config.json" -k "onedrive"
Save the following in a .py file in the same folder.
from graph_onedrive import OneDriveManager
# Use a context manager to manage the session
with OneDriveManager(config_path="config.json", config_key="onedrive") as my_drive:
# Print the OneDrive usage
my_drive.get_usage(verbose=True)
# Upload a file to the root directory
new_file_id = my_drive.upload_file("my-photo.jpg", verbose=True)
OneDriveManager is new in version 0.2.0. Refer docs for other instance constructors.
License and Terms of Use
This project itself is subject to BSD 3-Clause License detailed in LICENSE.
The Graph API is provided by Microsoft Corporation and subject to their terms of use.
Links
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 graph_onedrive-0.2.0.tar.gz
.
File metadata
- Download URL: graph_onedrive-0.2.0.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ffca15a5565545f5391e2b5e286b3e2be0b1c3d36f2c93979dc0f14c9fc6005 |
|
MD5 | 92135861752f8130450b629803aebd3e |
|
BLAKE2b-256 | 4a7076f4287dc42edf7732d0aa4f50cbe6ce9b00e71e2dc91bf281825efb76ca |
File details
Details for the file graph_onedrive-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: graph_onedrive-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f639b671ceb65b609474b4d7fd685d8bd92ee71574e0877cbb18aa1a3b0c5d84 |
|
MD5 | 6bd1d28062183029838bcc6c0d61880f |
|
BLAKE2b-256 | 4fdb6571c96145c3ef3e253b6601e28e808a758ed0fcb75fe7761a35607797c9 |