title: Microsoft Graph: how to get all groups reusing the token generated through ADAL
body: <p>I'm trying to use Microsoft Graph and I'm a little bit lost here. I'm using ADAL to authenticate my app (app id + secret) through the AuthenticationContext.AcquireTokenAsync method. The code looks like this:</p>
  
  <pre><code>AuthenticationContext AuthContext = new AuthenticationContext(Authority);
  ClientCredential ClientCredential = new ClientCredential(ClientId, AppKey);
  var result = await AuthContext.AcquireTokenAsync(
                                          "https://graph.windows.net", 
                                          ClientCredential);
  </code></pre>
  
  <p>Now, if I reuse the token with the Azure Graph, I can recover all the groups by using this code:</p>
  
  <pre><code>var url = $"https://graph.windows.net/myorganization/groups?api-version=1.6";
   var client = new HttpClient();
   client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", resultAccessToken);
    var response = await client.GetAsync(url);
    if (response.Content != null) {
         Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
  </code></pre>
  
  <p>According to the docs, I should use the newer Microsoft Graph API, but I'm having some issues when I try to use the following code:</p>
  
  <pre><code>var authenticationProvider = new DelegateAuthenticationProvider(
        req.Headers.Authorization = new AuthenticationHeaderValue("bearer", 
                                             resultAccessToken.AccessToken);
        return Task.CompletedTask;
  });
  var graph = new GraphServiceClient(authenticationProvider);
  var groups = await graph.Groups
                      .Request()
                      .GetAsync();
  </code></pre>
  
  <p>Whenever I run this, I end up getting the following exception:</p>
  
  <p>Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Microsoft.Graph.ServiceException: Code: InvalidAuthenticationToken
  Message: Access token validation failure.</p>
  
  <p>It's obvious that I'm missing something here, but what? (btw, I've managed to get everything working with the MSAL libraries, but in this case, I really need to have my component integrated with others that use ADAL),</p>
  
  <p>Thanks.</p>
  
  <p>Luis</p>