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.4.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.4-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fs_onedrivefs-1.2.4.tar.gz
  • Upload date:
  • Size: 596.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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.4.tar.gz
Algorithm Hash digest
SHA256 0f2a54e0706204060b7c4a43420cb8cc5eb7392667f2ed3d6daa33ad19d37191
MD5 17105fecb1d4e24297ab169e7a11cf5a
BLAKE2b-256 a852dc4575f964c088cd2a2fff6a0654d8bbcaf0b9133e0c11aa78578a9cc84e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fs_onedrivefs-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9f1c4dea3dea3d2f7cf4d0ca4bec9830997f16685c2e99b10ce708498fd69807
MD5 ea42e557b51190b04f66a07337c8b910
BLAKE2b-256 07df376d8894fa4954525d1a460e0bfac3af6a11b4d35bac8f34555c1c850ac9

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