title: Microsoft Graph API BadRequest Current authenticated context is not valid
body: <p>I am trying to develop a simple background app to connect to my onedrive account (work) and regularly download some files.</p>
  
  <p>I followed this tutorial <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-client-creds" rel="noreferrer">https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-client-creds</a></p>
  
  <p>I have registered the app here <a href="https://apps.dev.microsoft.com/portal/register-app" rel="noreferrer">https://apps.dev.microsoft.com/portal/register-app</a>
  I have written down the <code>client_id</code> and <code>client_secret</code></p>
  
  <p>To get an access token I make a POST request to </p>
  
  <p><a href="https://login.microsoftonline.com/common/oauth2/v2.0/token" rel="noreferrer">https://login.microsoftonline.com/common/oauth2/v2.0/token</a>
  with the following form encoded data</p>
  
  <pre><code>{
      'client_id': 'clientid here',
      'client_secret': 'secret is here',
      'scope': 'https://graph.microsoft.com/.default',
      'grant_type': 'client_credentials',
  }
  </code></pre>
  
  <p>I get back an <code>access_token</code> </p>
  
  <pre><code>{'ext_expires_in': 0,
   'token_type': 'Bearer',
   'expires_in': 3600,
   'access_token': 'eyJ0eXAiOiJKV1QiLCJhbGciO---SHORTENED FOR BREVITY'}
  </code></pre>
  
  <p>Next I make a GET request (with <code>Bearer</code> header properly set) to <a href="https://graph.microsoft.com/v1.0/me" rel="noreferrer">https://graph.microsoft.com/v1.0/me</a></p>
  
  <p>and get this eror response (which I get for any endpoint fwiw)</p>
  
  <pre><code>{
    "error": {
      "code": "BadRequest",
      "message": "Current authenticated context is not valid for this request",
      "innerError": {
        "request-id": "91059f7d-c798-42a1-b3f7-2487f094486b",
        "date": "2017-08-05T12:40:33"
      }
    }
  }
  </code></pre>
  
  <p>I have these permissions configured in the app setting
  <a href="https://i.stack.imgur.com/psN0s.png" rel="noreferrer"><img src="https://i.stack.imgur.com/psN0s.png" alt="permissions"></a></p>
  
  <p><strong>Any ideas what might be wrong?</strong></p>