Skip to main content

Perform simple tasks on OneDrive through the Graph API.

Project description

Tests pre-commit.ci status PyPI version Supported Python versions

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 -U graph-onedrive

Documentation

Documentation and examples are provided on GitHub in the docs folder.

A simple example

This is a simple example using a config file. Refer to the documentation for other instance constructors including inline options.

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)

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


Download files

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

Source Distribution

graph_onedrive-0.4.0.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

graph_onedrive-0.4.0-py2.py3-none-any.whl (26.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file graph_onedrive-0.4.0.tar.gz.

File metadata

  • Download URL: graph_onedrive-0.4.0.tar.gz
  • Upload date:
  • Size: 27.9 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.10

File hashes

Hashes for graph_onedrive-0.4.0.tar.gz
Algorithm Hash digest
SHA256 526656e30b8407d851128471ec5a6e2eb184bcbb3a90483180ff78920e76e59e
MD5 9b8ab7c79328852d3004fded9f3220fd
BLAKE2b-256 8ffb0b6ef151ad48f3d3494f5a7f294971f35f6f528518899f83d07951e8d1c1

See more details on using hashes here.

File details

Details for the file graph_onedrive-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: graph_onedrive-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 26.8 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.10

File hashes

Hashes for graph_onedrive-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 977da9c017a2add2ce46bd0c845bb7f98bb7dc7eb40a6f58ce57c0ae634f58f4
MD5 7a016272ff0470fada892c964fa18514
BLAKE2b-256 32762a2a5b6a0de080fd5056dcbe8a156e4e52baa4624533aed7d98dd90e7527

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