MS Graph API:找不到OneDrive资源 [英] MS Graph API: OneDrive resource not found

查看:93
本文介绍了MS Graph API:找不到OneDrive资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建使用以下方法通过Graph API连接到OneDrive for Business的Windows服务: https://graph.microsoft.io/en-us/docs/authorization/app_only

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

我已经成功验证了我的应用程序,并且具有用于调用Graph API的令牌.我已经向Windows Azure Active Directory和Microsoft Graph都授予了我的Azure AD应用程序权限(已为两者选择了所有应用程序和委派的权限).

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).

我的目标是获取位于特定用户的OneDrive中的文件夹的内容.我需要进行以下Graph API调用:

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

我可以使用Microsoft Graph Explorer(使用我的Office 365凭据登录)成功执行此请求.当我尝试与应用程序进行相同的调用时(使用上面收到的auth令牌),我得到一个带有消息找不到资源"的"itemNotFound"代码. (请求ID: 5e814dce-c4c2-4615-90e6-ea8ab90cbc49).但是,我能够查询根,并且"folder.childCount"属性在根中显示正确的子代数:

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

我已将文件夹的共享设置为所有经过身份验证的用户",但仍从API调用中收到找不到资源".

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?

推荐答案

该应用程序正在使用委派流,它由Graph Explorer使用.

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.

这篇关于MS Graph API:找不到OneDrive资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆