MS Graph API: 未找到 OneDrive 资源

MS Graph API: OneDrive resource not found

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

我已经成功验证了我的应用程序,并且有一个令牌可以调用 Graph API。我已将我的 Azure AD 应用程序权限授予 Windows Azure Active Directory 和 Microsoft Graph(已为两者选择所有应用程序和委派权限)。

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

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

我可以使用 Microsoft Graph 资源管理器(使用我的 Office 365 凭据登录)成功执行此请求。当我尝试与应用程序进行相同的调用时(使用上面收到的身份验证令牌),我得到一个 "itemNotFound" 代码和消息 "The resource could not be found." (请求 ID: 5e814dce-c4c2-4615-90e6-ea8ab90cbc49)。但是,我能够查询根并且 "folder.childCount" 属性 显示根中正确的子节点数:

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

我已将文件夹的共享设置为 "All Authenticated Users",但我仍然收到来自 API 电话的 "The resource could not be found"。

关于我在这里遗漏的任何想法?

应用程序正在使用 Graph Explorer 使用的 App-only authorization which is currently not supported for accessing OneDrive for Business through Microsoft Graph API. Please use delegated flow

标记的答案不再如此。您现在可以使用客户端凭据授权(又名 "App Only")访问 OneDrive 和 SharePoint 资源。

适用范围为Files.Read.AllFiles.ReadWrite.AllSites.Read.AllSites.ReadWrite.All