OneDrive Microsoft Graph error : Token contains invalid signature

OneDrive Microsoft Graph error : Token contains invalid signature

我正在尝试访问我的 OneDrive for Business 驱动器中的文件列表。

我遵循了 "Code Flow" 方法,我已经有了令牌并能够通过 https://graph.microsoft.com/v1.0/me?$select=mySite

获取我的端点

但是当我尝试列出文件时,使用 MyEndpoint/_api/v2.0/me/drive/root/children 我得到错误:

{"error":{"code":"unauthenticated","message":"Token contains invalid signature.","innerError":{"code":"invalidSignature"}}}

如果我将完整的 url 放入浏览器,我会得到 JSON 结果(在验证之后)。

帮忙?

您可以使用 MS Graph REST API 通过向 https://graph.microsoft.com/v1.0/me/drive/root/children 发送 GET 请求来列出用户 OneDrive 中的文件,而不是使用 MyEndpoint/_api/v2.0/me/drive/root/children。该请求应包含一个 header 以及具有 https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_list_children.

中列出的权限之一的令牌

此外,Graph explorer 有大量值得检查的 OneDrive 示例。要查看 OneDrive 示例,请单击 show more samples link。