Hi @David CPM ,
You can refer to following code to upload file.
from shareplum import Office365
from shareplum import Site
from shareplum.site import Version
authcookie = Office365('https://TenantName.sharepoint.com', username='******@TenantName.onmicrosoft.com', password='******').GetCookies()
site = Site('https://TenantName.sharepoint.com/sites/SiteName/', version=Version.v365, authcookie=authcookie);
folder = site.Folder('Shared Documents')
with open("D:\myfile.txt", mode='rb') as file:
fileContent = file.read()
folder.upload_file(fileContent, "myfile.txt")
You could also use Office365-Rest-Python-Client library to access to Sharepoint documents. https://github.com/vgrem/Office365-REST-Python-Client
Here are some examples about file operations: https://github.com/vgrem/Office365-REST-Python-Client/tree/master/examples/sharepoint/files
For SharePoint Online, please check if the user account which enabled MFA, then it's not supported, try to close MFA, you can check the detailed Conditional Access Policy as official document:
Troubleshooting sign-in problems with Conditional Access
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.