title: EWS Authentication: OAuth with service account
body: <p>I have below code and working fine when i am running the application from local machine.</p>
  <p>But I am getting below exception while running the same application using a service account</p>
  <pre><code>// Configure the MSAL client to get tokens
  var app = ConfidentialClientApplicationBuilder
      .Create(ConfigurationManager.AppSettings[&quot;appId&quot;])
      .WithAuthority(AzureCloudInstance.AzurePublic, ConfigurationManager.AppSettings[&quot;tenantId&quot;])
      .WithClientSecret(ConfigurationManager.AppSettings[&quot;clientSecret&quot;]).Build();
  
  // The permission scope required for EWS access
  var ewsScopes = new string[] { &quot;https://outlook.office.com/.default&quot; };
  
  //Make the toekn request
  AuthenticationResult authResult = await app.AcquireTokenForClient(ewsScopes).ExecuteAsync();
  
  
  Exception : An error occurred while sending the request. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task
  </code></pre>
  <p>Exception in is on
  AuthenticationResult authResult = await app.AcquireTokenForClient(ewsScopes).ExecuteAsync();</p>
  <p>Thanks in advance</p>
  <p>Regards,
  Nidheesh</p>