Hi,
Im trying to get acces to Exchange Online with the EWS manage api 2.2 and Im trying using this
ExchangeService service = new ExchangeService(); service.TraceEnabled = true; service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); //service.HttpHeaders.Add("Authorization", "Bearer " + token); service.Credentials = new TokenCredentials(token); //service.PreAuthenticate = true; //service.SendClientLatencies = true; //service.EnableScpLookup = false;
Always I get 401 unauthorized the token I get Azure Ad Authentication library , with this code
var authenticationContext = new AuthenticationContext(_config.AuthString, false); // Config for OAuth client credentials var clientCred = new ClientCredential(_config.ClientId, _config.ClientSecret); AuthenticationResult authenticationResult = authenticationContext.AcquireToken(_config.ResourceUrl,clientCred); string token = authenticationResult.AccessToken;
The app is registered on Azure Ad and have all the permision ,
Im missing something? There is somewhere a working example?
I thinks is the same problem that is explained here
Live like you'll die tomorrow, learn like you'll live forever.
Blog