Search code examples
asp.netonedrivemicrosoft-graph-api

Error when accessing OneDrive for Business via graph API


I have built a asp.net app that successfully accesses o365 exchange with an App Only Token and Graph. I am now trying to access a specific user's OneDrive for Business files with the same token and a Get request similar to the following:

https://mycomp-my.sharepoint.com/_api/v2.0/drives/[email protected]/items

but I get the following error:

3001000;reason='There has been an error authenticating the request.';category='invalid_client'

Any idea what is the cause of the error?


Solution

  • It's possible to do app-delegated access to OneDrive for Business today using the direct API endpoint and the Sites.ReadWrite.All app-delegated permission scope in AAD. I'd consider it more "in preview" than supported, so Yina's answer is technically correct. I'm still getting the documentation for how build an app finalized, but we'll be publishing something soon.

    Andrew Connell has a good blog post about how to get this setup, available here: http://www.andrewconnell.com/blog/user-app-app-only-permissions-client-credentials-grant-flow-in-azure-ad-office-365-apis

    Use of the OneDrive API is possible using this same method.