'Connecting with EWS API service to outlook.com account with oAuth2 token

I'm able to authenticate with live.com with my account on outlook.com at url

https://login.microsoftonline.com/common/v2.0

I receive an accessToken and id token.

My question is whether I can use this accessToken to retrieve exchange data about my emails through EWS API service using this token? ExchangeService.

   _exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1) { ConnectionGroupName = Guid.NewGuid().ToString() };
                    _exchangeService.Credentials = new WebCredentials("xxxxxxx", "xxxxxxxx", "outlook.com");
                 //  _credentials = new OAuthCredentials(user.PasswordToken);
                    // Set the URL.
                    _exchangeService.TraceEnabled = true;
                    _exchangeService.AutodiscoverUrl("xxxxx")

Authenticate to Outlook 365 through the ExchangeService.asmx in the following URL for exchange service as done in the following sample.

> https://outlook.office365.com/EWS/Exchange.asmx

My question is whether I can retrieve email data from exchange service ASMX with the idToken/accessToken supplied from live.com for outlook.com accounts?



Solution 1:[1]

I believe EWS still works for Outlook.com accounts with BASIC(username,password) auth. We used to use it before migrating to Graph API. You'd need to ask your Outlook users to generate a special App Password though.

To simplify your Exchange/Outlook integrations check out Aurinko API

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexey