
Hi @ASH2212 ,
According to my research, does the SharePoint account you used have MFA (Multi-Factor Authentication)? If yes, I recommend that you try to connect to SharePoint site using the following code:
site_url = 'https://contoso.sharepoint.com/'
app_principal = {
'client_id': '--client-id-goes-here--',
'client_secret': '--client-secret-goes-here--',
}
context_auth = AuthenticationContext(url=site_url)
context_auth.acquire_token_for_app(client_id=app_principal['client_id'], client_secret=app_principal['client_secret'])
ctx = ClientContext(site_url, context_auth)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web site title: {0}".format(web.properties['Title']))
In addition, our forum mainly discuss about SharePoint development using C#, as your issue is about Python, we suggest you can create a new thread on techcommunity for help.
techcommunity :
https://techcommunity.microsoft.com/t5/sharepoint-developer/bd-p/SharePointDev
Hope it can help you. Thanks for your understanding.
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.