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

Copper Contributor

Hi,

 

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?

 

Thanks

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) :

https://www.emailarchitect.net/eagetmail/sdk/html/object_oauth_ews_service.htm

https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#fi...

 

Thanks

 

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