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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fs_onedrivefs-1.2.3.tar.gz.
File metadata
- Download URL: fs_onedrivefs-1.2.3.tar.gz
- Upload date:
- Size: 596.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2331cafa23c4ea5969fb1690df7e5507377aba63844ebc317e6d3d91fe4fda61
|
|
| MD5 |
a7b203393f7d74dcc3d98bee07c78e36
|
|
| BLAKE2b-256 |
cb4160e3ade478a564b0e763f561e1b59624341e3f06d8b5a8e6e0f754abe460
|
File details
Details for the file fs_onedrivefs-1.2.3-py3-none-any.whl.
File metadata
- Download URL: fs_onedrivefs-1.2.3-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04e183dcb4995b1e048e61b5ee39dda1309fc54db597f337b523250ac48b5796
|
|
| MD5 |
d77be99b3b30b886fe09a52cc3b87972
|
|
| BLAKE2b-256 |
2846b72e481951a99141f002d8c8470d69f34c7a7e4205808691dedaf12f37cf
|