Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS Manage Api Exchange Online TokenCredentials always returning 401

$
0
0

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



Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>