IMAP login to office365

Copper Contributor

Hello everyone
I am ROR developer working on a application in which I have to read emails received on this office365 account via IMAP but currently I am not able to login via IMAP (did logged in once about 5 to 6 months ago by disabling "security defaults", but this thing is not working now).
I don't have enough technical knowledge of Azure or Exchange I just want to login remotely using IMAP and read emails. I went through the docs but at the end, I was just confused.
Preferably I want to login without following OAUTH flow if it is possible on today's date (26 sept 23) but if there is no way forward without OAUTH then guide me to login using OAUTH.
Please tell what i need enable/disable , 2FA, security defaults anything else. as It is urgent. thank you.

5 Replies
Only OAuth is supported nowadays, as Microsoft pulled the plug on any basic authentication methods in the service, "plain" IMAP included. If you have an app that leverages IMAP, you need to update it to use leverage OAuth to get an access token/SASL XOAUTH2 encode and transmit it, as detailed here: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-...
First of all, thank you Vasil for sparing time.
Google terminated plain IMAP access last year but we use plain authentication by enabling 2FA and then using app password so havn't microsoft provided any way like this to use plain authentication.
They did, but that's not a real solution to the basic auth problem. So now that basic auth is deprecated, you have to switch to OAuth/SASL XOAUTH2.

@Vasil, actually it is urgent and at the moment I just want to retrieve emails from Inbox so conventions and rules are secondary things. So I shall be grateful to you if you can guide me in that specific way/method other than OAUTH. Surely I am going to migrate to XOAUTH2 later on. Thank you.

There is no other way. If you simply want to access a give mailbox via IMAP (as a user), use a client that supports Modern auth. Thunderbird for example. If you are creating your own solution, make sure to leverage OAuth.
As mentioned above, basic auth method have been disabled in O365. Even if you toggle Security defaults, there is no way to re-enabled basic auth. Details are for example here: https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basi...