Search code examples
asp.net-mvcasp.net-coreoffice365microsoft-graph-apionedrive

OneDrive for Business File Read/Write with Application Permission already supported?


I would like my app to access (read/write) Onedrive files of a specific Office-Account with Application Permission only (to be clear: not a delegated permission). documentation is very sketchy about this. Is this is even currently supported? I read a post form 2016 which stated it was not at that time.

I am using Microsoft Graph as the API, A web-app based on .Net Core 2.2 and VS2019 as the IDE. The app is properly registered in Azure Active Directory with application permissions for files read/write

My App is able to:

  • To get an Access Token
  • To read Sharepoint Sites (https://graph.microsoft.com/v1.0/drive/root/children)
  • I cannot read/write the Onedrive files however (https://graph.microsoft.com/v1.0/me/drive/root/children)

Solution

  • I believe this scenario is supported. Note above you used v1.0/me but "me" doesn't mean anything in application context since the requests aren't made on behalf of a user. Try using /users/{id or user principal name}/drive/etc instead. If this doesn't help please update your post with the failed request id, timestamp and the exact error response. Request id is available in response headers from Graph.