title: MS Graph API rejects token
body: <p>I'm trying to create a node.js service to access my user's calendar and send invites to others through MS Graph API. </p>
  
  <p>Therefor I followed this guide:
  <a href="https://docs.microsoft.com/en-us/graph/auth-v2-service" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/graph/auth-v2-service</a></p>
  
  <pre><code>const endpoint = "https://login.microsoftonline.com/[tenant]/oauth2/token";
  const requestParams = {
      grant_type: "client_credentials",
      client_id: "[appid]",
      scope: 'https://graph.microsoft.com/.default',
      client_secret: "[password/secret]"
  };
  
  request.post({ url:endpoint, form: requestParams }, function (err, response, body) {
      if (err) {
          console.log("error");
      }
      else {
          //console.log("Body=" + body);
          let parsedBody = JSON.parse(body);         
          if (parsedBody.error_description) {
              console.log("Error=" + parsedBody.error_description);
          }
          else {
              console.log("Access Token=" + parsedBody.access_token);
              requestData(parsedBody.access_token)
          }
      }
  });
  
  function requestData(accessToken) {
      request.get({
          url: "https://graph.microsoft.com/v1.0/me/calendars",
          headers: {
            "Authorization": "Bearer " + accessToken
          }
      }, function(err, response, body) {
          console.log(body);
      });
  }
  </code></pre>
  
  <p>I could successfully retrieve an access token but when I try to request any of the Graph APIs I receive an error:</p>
  
  <pre><code>{
    "error": {
      "code": "InvalidAuthenticationToken",
      "message": "Access token validation failure.",
      "innerError": {
        "request-id": "..",
        "date": "2019-02-17T09:44:09"
      }
    }
  }
  </code></pre>
  
  <p>Any hints what I might have done wrong?</p>