title: Getting Azure Active Directory groups in asp.net core project
body: <p>I created a new project using Visual Studio 2015 and enabled authentication using work and school accounts against Azure Active Directory. 
  Here is what the generated configure function looks like:</p>
  
  <pre class="lang-cs prettyprint-override"><code>app.UseStaticFiles();
  app.UseCookieAuthentication();
  app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
  {
      ClientId = Configuration["Authentication:AzureAd:ClientId"],
      ClientSecret = Configuration["Authentication:AzureAd:ClientSecret"],
      Authority = Configuration["Authentication:AzureAd:AADInstance"] + Configuration["Authentication:AzureAd:TenantId"],
      CallbackPath = Configuration["Authentication:AzureAd:CallbackPath"],
      ResponseType = OpenIdConnectResponseType.CodeIdToken
  });
  
  app.UseMvc(routes =&gt;
  {
      routes.MapRoute(
          name: "default",
          template: "{controller=Home}/{action=Index}/{id?}");
  });
  </code></pre>
  
  <p>Here is the rudimentary action code trying to get user groups:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public async Task&lt;IActionResult&gt; Index()
  {
      var client = new HttpClient();
      var uri = "https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version=1.6";
  
      var response = await client.GetAsync(uri);
      if (response.Content != null)
      {
          ViewData["response"] = await response.Content.ReadAsStringAsync();
      }
  
      return View();
  }    
  </code></pre>
  
  <p>What do I need to use or change this code to make sure I can get user groups?
  Currently, the response is:</p>
  
  <pre><code>{  
     "odata.error":{  
        "code":"Authentication_MissingOrMalformed",
        "message":{  
           "lang":"en",
           "value":"Access Token missing or malformed."
        },
        "values":null
     }
  }
  </code></pre>