如何通过 Microsoft Graph 访问 Onedrive Business API

How to access Onedrive Business via Microsoft Graph API

我正在使用 Microsoft Graph 提供的 API 访问用户的个人文档,但我遇到了身份验证问题。

根据这个 documentation 我可以简单地创建一个应用程序,设置正确的范围(等),然后为给定的用户获取访问令牌 - 这现在工作得很好。

查询像 https://graph.microsoft.com/v1.0/me/drives works - I get a https://onedrive.live.com 这样的 URL 结果驱动器。

API 没有 return 的是关于 https://{tenant}-my.sharepoint.com. I have tried accessing this data using the API Endpoint: https://{tenant}-my.sharepoint.com/_api/v2.0 上使用 Microsoft Graph 身份验证令牌的第二个驱动器的数据。此 return 出现以下错误:

{
    "error_description": "Unsupported security token."
}

如何访问此类 Office 365 OneDrive 的 API?

sharepoint.com/_api/v2.0 API 不是 Microsoft Graph API,它不支持来自 v2 终结点的融合身份验证令牌。

访问 SharePoint Drives 使用与 OneDrive 和 OneDrive for business 相同的API:

/v1.0/sites/{siteId}/drives

例如,如果您有一个名为 "AwesomeTeam" 的团队站点,您可以使用以下方法检索该站点的 list of drives

/v1.0/sites/root/:/teams/AwesomeTeam:/drives