如何通过Microsoft Graph API访问Onedrive Business

时间:2018-02-09 12:46:11

标签: sharepoint office365 microsoft-graph onedrive

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

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

查询https://graph.microsoft.com/v1.0/me/drives等网址有效 - 我得到了https://onedrive.live.com个驱动器。

API无法返回的是https://{tenant}-my.sharepoint.com上有关第二个驱动器的数据。我尝试使用API​​端点:https://{tenant}-my.sharepoint.com/_api/v2.0使用Microsoft Graph身份验证令牌访问此数据。这将返回以下错误:

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

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

1 个答案:

答案 0 :(得分:1)

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

访问SharePoint Drives使用与OneDrive和OneDrive相同的API用于业务:

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

例如,如果您的团队网站名为" AwesomeTeam"您使用以下网址检索该网站的list of drives

/v1.0/sites/root/:/teams/AwesomeTeam:/drives
相关问题