Search code examples
python-3.xoffice365exchangelib

Python exchangelib Invalid credentials


I have a python script that pulls attachments from Office 365 mailbox using exchangelib. It was working fine up until couple of days ago when I started to get an error:

Invalid credentials for https://outlook.office365.com/EWS/Exchange.asmx

I suspect this is a due to a updates that Microsoft did for Office 365. The credentials are correct and account has EWS enabled. I will appreciate any suggestions how to solve this.


Solution

  • I believe Office365 finally switched off Basic Authentication. In that case, you need to use OAuth instead. See https://ecederstrand.github.io/exchangelib/#oauth-on-office-365 for a guide on doing that.