-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
Bug Description
The FileSystemTokenBackend class constructor doesn't seem to accept a cryptography_manager parameter, despite this document suggested so: https://o365.github.io/python-o365/latest/usage/utils/token.html
Environment
- O365 Version: 2.1.7
- Python Version: 3.12.1
- Operating System: Windows 11
Expected Behavior
cryptography_manager should be a valid parameter in FileSystemTokenBackend.
Actual Behavior
The FileSystemTokenBackend constructor only accepts token_path and token_filename parameters:
FileSystemTokenBackend.__init__(self, token_path=None, token_filename=None)Attempting to pass a cryptography_manager parameter results in:
TypeError: FileSystemTokenBackend.__init__() got an unexpected keyword argument 'cryptography_manager'
Code to Reproduce
from O365 import Account, FileSystemTokenBackend
from cryptography.fernet import Fernet
import os
# This fails with TypeError
key = Fernet.generate_key()
f = Fernet(key)
token_backend = FileSystemTokenBackend(
token_path="/path/to/tokens",
token_filename="token.txt",
cryptography_manager=f # This parameter is not accepted
)Investigation
I inspected the FileSystemTokenBackend class and confirmed its signature:
>>> from O365.utils.token import FileSystemTokenBackend
>>> import inspect
>>> print(inspect.signature(FileSystemTokenBackend.__init__))
(self, token_path=None, token_filename=None)Suggested Solutions
class FileSystemTokenBackend:
def __init__(self, token_path=None, token_filename=None, cryptography_manager=None):
self.cryptography_manager = cryptography_managerMetadata
Metadata
Assignees
Labels
No labels