title: Microsoft Graph Api : Insufficient privileges to complete the operation
body: <p>I'm trying to download files from OneDrive using the Microsoft Graph. I'm currently in the testing phase and have not yet written any code.</p>
  
  <p>Here is what I did so far:</p>
  
  <ol>
  <li>Created and registered an app through <a href="https://apps.dev.microsoft.com" rel="nofollow noreferrer">https://apps.dev.microsoft.com</a></li>
  <li>Generated a secret, enabled implicit flow </li>
  <li><p>Provided it with the following list of Microsoft Graph Permissions:</p>
  
  <p><strong>Delegated</strong>: <code>Files.ReadWrite.All</code>, <code>offline_access</code>, <code>Group.ReadWrite.All</code>, <code>Directory.ReadWriteAll</code>, <code>User.ReadWriteAll</code></p>
  
  <p><strong>Application</strong>: <code>Directory.ReadWrite.All</code>, <code>Files.ReadWrite.All</code>,  <code>Group.ReadWrite.All</code>, <code>User.ReadWrite.All</code></p>
  
  <ol start="4">
  <li><p>Used the <code>code</code> flow with a scope of <code>offline_access</code> and <code>Files.ReadWrite.All</code>, got a code and then a token.</p></li>
  <li><p>Using this token to download a file via <code>/me</code> drive works well (<code>/v1.0/me/drive/items/itemid/content</code>), but when I try to download or just query other users I get back the error of insufficient privileges.</p></li>
  </ol></li>
  </ol>
  
  <p>Calling <code>https://graph.microsoft.com/v1.0/users</code> gets the response:</p>
  
  <pre><code>{
    "error": {
      "code": "Authorization_RequestDenied",
      "message": "Insufficient privileges to complete the operation.",
      "innerError": {
        "request-id": "cee06586-12af-4768-9135-b9709d7ecb5d",
        "date": "2018-05-29T14:45:48"
      }
    }
  }
  </code></pre>
  
  <p>The same happens when I add a user Id. When I ask to get the user's device I get a "not found" response. </p>
  
  <p>I saw some answers to similar questions saying that I should add permissions to my app to Azure Active Directory via the Azure portal, but my app is listed only in the "Enterprise application" section and I don't see it on the "app registrations" section where I can add permissions, in the Enterprise applications section I'm unable to add any permissions, only search.</p>
  
  <p>Note: my user id is the global admin in the Azure portal. This user also is the user that created and owns the application.</p>
  
  <p>Any idea what I may be missing here?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong>:</p>
  
  <p>I was able to make some progress, I tried to create the app via the Azure portal and not the applications portal. Now it shows in the app registration page so I was able to add permissions to it.</p>
  
  <p>So now I'm able to view all the users, but still, when I try to view their drive I get the "not found" response:</p>
  
  <p>Calling <code>https://graph.microsoft.com/v1.0/users/userid/drive</code> returns the response: </p>
  
  <pre><code>{
    "error": {
      "code": "itemNotFound",
      "message": "The resource could not be found.",
      "innerError": {
        "request-id": "ec6ed197-15ea-498a-80d0-e2a9f832a0b9",
        "date": "2018-05-29T15:49:18"
      }
    }
  }
  </code></pre>