I\'m trying to log onto Office 365 Exchange Online using OAuth and EWS Managed API.
I am able to use connect to the Office 365 Web API\'s (REST), so I do have a vali
You can use OAuth to connect to EWS (as opposed to REST), however, it's not as smooth. EWS requires the special "Have full access to a user's mailbox" delegated permission in Azure Active Directory, which requires an administrator to register it. This permission also doesn't "travel" outside the organization, so there is no user-consent scenario for EWS. Essentially, the only scenario that this works for is an administrator registering the application for your own organization.
Check your app registration in Azure and make sure you have that permission assigned.
Assuming that you have the permission assigned, I've made this work in two ways.
The simplest: Just add the token you get back to the request headers in an Authorization header, like so:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
string accessToken = GetAccessToken();
if (!string.IsNullOrEmpty(accessToken))
service.HttpHeaders.Add("Authorization", "Bearer " + accessToken);