首页 文章

如何通过Microsoft Graph API访问Onedrive Business

提问于
浏览
0

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

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

查询像https://graph.microsoft.com/v1.0/me/drives这样的网址 - 我得到了一个https://onedrive.live.com驱动器 .

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

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

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

1 回答

  • 1

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

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

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

    例如,如果您有一个名为"AwesomeTeam"的团队网站,则使用以下命令检索该网站的list of drives

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

相关问题