MS Graph API: OneDrive resource not found

删除回忆录丶 提交于 2019-12-19 10:17:03

问题


I'm building a Windows service that connects to OneDrive for Business via the Graph API using this method: https://graph.microsoft.io/en-us/docs/authorization/app_only

I've successfully authenticated my application and have a token for making calls to Graph API. I have given my Azure AD application permissions to both Windows Azure Active Directory and Microsoft Graph (all application and delegated permissions have been selected for both).

My goal is to get the contents of a folder that resides in a specific user's OneDrive. I need to make the following Graph API call:

//graph.microsoft.com/v1.0/users('user-guid')/drive/items/long-item-id-here/children

I can execute this request successfully using Microsoft Graph Explorer (logged in with my Office 365 credentials). When I try to make the same call as an application (using the auth token received above), I get an "itemNotFound" code with the message "The resource could not be found." (request-id: 5e814dce-c4c2-4615-90e6-ea8ab90cbc49). However, I am able to query the root and the "folder.childCount" property shows the correct number of children in the root:

//graph.microsoft.com/v1.0/users('user-guid')/drive/root

I've set the folder's sharing to "All Authenticated Users" and I still receive "The resource could not be found" from the API call.

Any ideas on what I'm missing here?


回答1:


The application is using App-only authorization which is currently not supported for accessing OneDrive for Business through Microsoft Graph API. Please use delegated flow, which is used by Graph Explorer.




回答2:


The marked answer is no longer the case. You can now access OneDrive and SharePoint resources using a Client Credentials grant (aka "App Only").

The applicable scopes are Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All



来源:https://stackoverflow.com/questions/35878044/ms-graph-api-onedrive-resource-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!