Skip to main content

Pyfilesystem2 implementation for OneDrive using Microsoft Graph API

Project description

fs.onedrivefs

Implementation of pyfilesystem2 file system using OneDrive

image codecov PyPI version

Usage

fs.onedrivefs can create a requests_oauthlib.OAuth2Session for you. This way the OAuth2Session is going to refresh the tokens for you.

onedriveFS = OneDriveFS(
  clientId=<your client id>,
  clientSecret=<your client secret>,
  token=<token JSON saved by oauth2lib>,
  SaveToken=<function which saves a new token string after refresh>)

# onedriveFS is now a standard pyfilesystem2 file system

You can handle the tokens outside of the library by passing a niquests.Session. Here is an example of a custom session using MSAL Python

class MSALSession(OAuth2Session):
  def __init__(self, client: msal.ClientApplication):
    super().__init__()
    self.client = client

  def request(self, *args, **kwargs):
    account = self.client.get_accounts()[0]
    self.token = self.client.acquire_token_silent_with_error(
      scopes=["Files.ReadWrite"], account=account
    )

    return super().request(*args, **kwargs)

client = msal.ConfidentialClientApplication(
  client_id=<your client id>,
  client_credential=<your client secret>,
  authority=f"https://login.microsoftonline.com/<your tenant>",
  token_cache=<your token cache>,
)

# Authentication flow to populate the token cache
# YOUR AUTHENTICATION FLOW

session = MSALSession(client=client)
onedriveFS = OneDriveFS(session=session)

# onedriveFS is now a standard pyfilesystem2 file system

Register your app here to get a client ID and secret

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

fs_onedrivefs-1.2.5.tar.gz (596.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fs_onedrivefs-1.2.5-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file fs_onedrivefs-1.2.5.tar.gz.

File metadata

  • Download URL: fs_onedrivefs-1.2.5.tar.gz
  • Upload date:
  • Size: 596.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fs_onedrivefs-1.2.5.tar.gz
Algorithm Hash digest
SHA256 658904f676ad354a79dfcd170134f256a776dd3868d5e63121c14a10651c15ea
MD5 145f57984dc89579ddcb9897f2f3f83c
BLAKE2b-256 40b73cb71a75540be3d006d0651062e15335e11d54a05499b81ee1b49afa9054

See more details on using hashes here.

File details

Details for the file fs_onedrivefs-1.2.5-py3-none-any.whl.

File metadata

  • Download URL: fs_onedrivefs-1.2.5-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fs_onedrivefs-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7881530379b2bcdfbbca3301a0ea3595a07fab1b2294663bf85beaa3d989d778
MD5 de332ce862426510c91966fa37067980
BLAKE2b-256 d07b6a01a2ad2a5a4ae9c32b3bc078e3d970c6f7b75da1283eee666e04182f99

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page