Replacing basic auth for IMAP with OAuth 2.0 in an unattended application

Copper Contributor



We have an automated process that reads incoming emails and extract attachments from an O365 inbox which has IMAP basic auth enabled. The org wants to disable basic auth and have us use either OAuth 2.0 or even better not use IMAP. Is there a recommended way to achieve this?


Can we use OAuth 2.0 authentication from a C# service application? Or is user input required for OAuth 2.0?


Are we able to move away from IMAP?



2 Replies

Hey @Shivian D,


I am by no means a developer but i have somewhat heard about the question you raised. Oauth 2.0 does support authentication against office 365 services without user intervention. To start off you will have to register the application in azure and retrieve a 'client id' and 'client secret' which you can later use in the code for obtaining a token. The following articles should help you get started (EWS) :




@harveer singhaha that does sound promising. Thanks - will investigate that.