Pyfilesystem2 implementation for OneDrive using Microsoft Graph API
Project description
fs.onedrivefs
Implementation of pyfilesystem2 file system using OneDrive
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 requests.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
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
fs_onedrivefs-1.2.1.tar.gz
(595.8 kB
view details)
Built Distribution
File details
Details for the file fs_onedrivefs-1.2.1.tar.gz
.
File metadata
- Download URL: fs_onedrivefs-1.2.1.tar.gz
- Upload date:
- Size: 595.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdd5d28d1d1c51fea31f36fe3ab9f76c1e62ee3420550c5119f99afc90c942ef |
|
MD5 | e3a2d7625c0271fc0d6eacf009079b1c |
|
BLAKE2b-256 | 93efe0a4468b099232e672c7f0e1668292192d4631ebe1d294dbd75285f46002 |
File details
Details for the file fs_onedrivefs-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: fs_onedrivefs-1.2.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0e17084d57190f3c6cb7f0d50aada860a7e0cb0b7400ce417137f0be7e5b95e |
|
MD5 | 6f73819834496c698a322965728053b3 |
|
BLAKE2b-256 | 85762a17e53c0b4827ca98fc95e08c61f4a2c6755505170782aa69d94b79d292 |