尝试使用客户端凭据(App)令牌在驱动器上执行search操作,如下面的URL:
https://graph.microsoft.com/v1.0/groups/{GROUP_ID}/drive/root/search(q='newFileTest.docx')
...导致403错误:
{
"error": {
"code": "accessDenied",
"message": "The caller does not have permission to perform the action.",
"innerError": {
"request-id": "**redacted**",
"date": "2019-04-17T12:47:10"
}
}
}
客户端具有Files.ReadWrite.All
权限,这是执行搜索查询所必需的,并且可以无任何问题地读/写文件夹和文件。
使用Delegated Auth执行相同的命令(所以使用登录用户,例如Microsoft Graph Explorer),但返回0结果(有关详细信息,请参阅this bug)。
这对我来说似乎是一个错误,但如果有人认为不是,我会很高兴听到。
事实证明,对于Search来使用Client Credentials,应用程序需要具有Sites.ReadWrite.All
权限。 Files.ReadWrite.All
权限是不够的,即使文档提到“调用此API需要以下权限之一”。提交了Microsoft Docs GitHub issue。