goryef
goryef

Reputation: 1489

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.

Upvotes: 1

Views: 6324

Answers (2)

MUHAMMED FAISAL P J
MUHAMMED FAISAL P J

Reputation: 1

I tried to login microsoft account that provided on code using browser. Then it logged in. After that I closed. Then again checked python code for accessing mailbox using exchangelib. It worked. I think it taking any session or something. Before that it gives error like exchangelib.errors.UnauthorizedError: Invalid credentials for https://outlook.com/autodiscover/autodiscover.svc

Upvotes: 0

Erik Cederstrand
Erik Cederstrand

Reputation: 10245

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.

Upvotes: 3

Related Questions