Today we have an application to sync appointments to Exchange. We have several customers using different versions of Exchange, i.e: Exchange 2010, o365. Each customer have created a Service Account with impersonation rights that we use for authentication. An example:
var credentials = new WebCredentials(serviceAccount.username, serviceAccount.password);
var service = new ExchangeService
{
Credentials = credentials,
Url = new Uri(exchangeUri)
}
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, email);
So this method will not work anymore from October 13 2020, and we will have to use OAuth instead. I have read the MS documentation "Authenticate an EWS application by using OAuth": https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth
I have registered my application in Azure AD, and got an Application Id. I guess I am supposed to use "Application permissions", and following code to get the token:
// Configure the MSAL client to get tokens
var app = ConfidentialClientApplicationBuilder
.Create(ConfigurationManager.AppSettings["appId"])
.WithAuthority(AzureCloudInstance.AzurePublic, ConfigurationManager.AppSettings["tenantId"])
.WithClientSecret(ConfigurationManager.AppSettings["clientSecret"]).Build();
// The permission scope required for EWS access
var ewsScopes = new string[] { "https://outlook.office.com/.default" };
//Make the toekn request
AuthenticationResult authResult = await app.AcquireTokenForClient(ewsScopes).ExecuteAsync();
My questions:
Any help/suggestions are greatly appreciated.