The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Hi @KKS,
Thank you for reaching out to the Microsoft Q&A Forum.
Based on my research, direct username/password authentication is not recommended, especially if MFA is enabled. You can refer to this link for more information > Azure sharepoint multi-factor authentication with python - Stack Overflow
You can connect your Microsoft account with Python using the Microsoft Authentication Library (MSAL) for OAuth 2.0.
To do this, you need to meet two prerequisites:
- An Azure account with an active subscription. Create a free account if you don't have one.
- Python 3.6+.
Then, please follow the instruction in this link to acquire tokens to access Microsoft Graph API, SharePoint, Outlook and other service. Overview of the Microsoft Authentication Library (MSAL) for Python - Microsoft Authentication Library for Python | Microsoft Learn
You can also explore the broader Microsoft Authentication Libraries (MSAL) documentation | Microsoft Learn for additional authentication flows and implementation details
Please note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
I hope this helps! If you have any other questions, feel free to ask.
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