title: Insufficient privileges to complete the operation when using service principal to create Azure AD Application
body: <p>Following the code outlined here:</p>
  
  <pre><code>https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console/blob/master/GraphConsoleAppV3/Program.cs#L810
  </code></pre>
  
  <p>but using a Service Principal to authenticate one will get a Insufficient Privileges error when trying to create the application on</p>
  
  <pre><code>client.Applications.AddApplicationAsync(appObject).Wait();
  </code></pre>
  
  <p>with token exchange like the following:</p>
  
  <pre><code>var context = new AuthenticationContext($"https://login.microsoftonline.com/{tenantId}");
  var token = context.AcquireToken("https://graph.windows.net", new ClientCredential(clientId, secret));    
  var client = new ActiveDirectoryClient(new Uri($"https://graph.windows.net/{tenantId}"),()=&gt;Task.FromResult(token.AccessToken));
  </code></pre>