【发布时间】:2019-02-12 10:36:28
【问题描述】:
我正在尝试调用驱动器上 OneDrive API 的搜索端点(即https://graph.microsoft.com/v1.0/drives/{drive-id}/root/search(q='mysearchterm').
这在 Graph Explorer 上运行良好,但是,我没有在同一驱动器上使用客户端凭据流获得任何搜索结果。
我的应用注册具有 API 文档(Files.Read.All、Files.ReadWrite.All、Sites.Read.All、Sites.ReadWrite.All)中提到的所有必需的应用程序权限,并且读取驱动器、驱动器项、下载驱动器项都可以正常工作。不工作的一件事是搜索驱动器项目。我只是得到一个空数组,没有错误;
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)","value":[]}
我将 adal-node 与 acquireTokenWithClientCredentials 一起使用。
var adal = require("adal-node");
const TENANT = "{tenant-name-here}.onmicrosoft.com";
const CLIENT_ID = "{Application-id-here}";
const CLIENT_SECRET = "{Application-key-here}";
function getToken() {
return new Promise((resolve, reject) => {
const authContext = new adal.AuthenticationContext(
`https://login.microsoftonline.com/${TENANT}`
);
authContext.acquireTokenWithClientCredentials(
GRAPH_URL,
CLIENT_ID,
CLIENT_SECRET,
(err, tokenRes) => {
if (err) {
reject(err);
}
resolve(tokenRes.accessToken);
}
);
});
}
我正在搜索的驱动器是 SharePoint 文档库。
【问题讨论】:
标签: node.js microsoft-graph-api onedrive adal