Exact steps required to implement Oauth 2.0 authentication in an EWS console application

Viewed 65

As per below link of Microsoft, all the legacy protocol using applications need to be have modern authentication.

https://docs.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online#exchange-web-services-ews

Our application is a console application(Exchange Web Services (EWS)) that runs through a task schedular every 10 minutes.

It basically processes the emails using Aspose Email dll(version 22.8)

So what exactly we need to do from scratch to move it to modern authentication so that it work the same way after microsoft removes basic authentication on these protocols post October 1 2022.

1 Answers
  1. Decided whether your going to use Delegate or Application permissions, eg how does you app run at the moment if it use EWS Impersonation then the Client Credentials Flow is the most appropriate to use
  2. Read https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth and create an Application registration and consent to it that contains either Delegate or Application Permission. If you using the Client Credential flow use a Certificate for Auth
  3. Apose has it own support for oAuth Authentication see https://docs.aspose.com/email/net/access-mail-services-using-oauth/ (IMO there examples aren't great what i would suggest you do is use MSAL https://github.com/AzureAD/microsoft-authentication-library-for-dotnet for the Authentication and implement that in https://reference.aspose.com/email/net/aspose.email.clients/itokenprovider/ that should give you a more robust and reliable authentication process.)
Related