【问题标题】:Microrsoft Graph query returns empty value on APIMicrosoft Graph 查询在 API 上返回空值
【发布时间】:2018-08-14 07:18:34
【问题描述】:

我正在使用 python 脚本从用户 office 365 onedrive 备份文件。我使用 Graph API 从用户 onedrive 获取对象列表。 我从用户的根驱动器获取所有子对象的查询在 Graph Explorer 中返回了预期值。在 python 脚本中使用相同的查询时,Graph 返回一个空值。脚本中的其他查询正在返回正确的值。

返回正确值的查询示例: https://graph.microsoft.com/v1.0/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/drives 脚本从返回值中提取 drive-id 以从下一个查询中获取子对象列表: https://graph.microsoft.com/v1.0/users('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/drives('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/root/children

从 API 调用返回空值,但从 Graph explorer 返回正确的值。

有什么建议吗?

【问题讨论】:

  • 您是否正在针对 OneDrive 商业用户拨打电话?您在令牌中请求了哪些范围?

标签: api sharepoint graph onedrive


【解决方案1】:

您需要为 graphScopes 变量添加适当的权限

我试图使用 javascript 代码获取一个驱动器文件的列表,然后我使用了这个配置

var applicationConfig = {
clientID: "ea5*****-c721-4f13-a***-369f8c******",
graphScopes: ["user.read"],
graphEndpoint: "https://graph.microsoft.com/v1.0/me",
webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
};

它给出的是空列表,但后来我在配置中更改了 graphScopes

var applicationConfig = {
clientID: "ea5*****-c721-4f13-a***-369f8c******",
graphScopes: ["Files.Read.All","Sites.Read.All"],
graphEndpoint: "https://graph.microsoft.com/v1.0/me",
webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
};

然后它给了我它在 GraphExplorer 中给出的列表

【讨论】:

    猜你喜欢
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多