【问题标题】:Getting WAC access token error when calling Microsoft Graph API调用 Microsoft Graph API 时出现 WAC 访问令牌错误
【发布时间】:2019-06-13 08:41:43
【问题描述】:

我第一次使用 Microsoft Graph。我正在致电https://graph.microsoft.com/beta/me/drive/items/root:/STWTest.xlsx:/workbook/ 并收到以下回复:

{
    "error": {
        "code": "AccessDenied",
        "message": "Could not obtain a WAC access token.",
        "innerError": {
            "request-id": "28dc972e-b8ce-4b5c-bfbe-2bd29094c878",
            "date": "2019-06-13T08:35:23"
        }
    }
}

关于如何解决此错误的任何想法?

【问题讨论】:

    标签: office365 microsoft-graph-api


    【解决方案1】:

    我知道 OP 已经回答了他们自己的问题,但在我的情况下,解决方案有所不同。

    我只是使用了错误的 DriveItem(即文件)ID(来自错误的驱动器)。

    如果您使用的是 Teams 并且正在处理嵌入的 SharePoint 网站中的文件,这里是获取(或仔细检查)必要 ID 的一种方法:

    1. 您所属的组 (~=Teams)(从该命令的结果中复制您想要的 Team 的 id 字段): https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group
    2. 团队的频道(在下面的 url 中替换 {team-id},并从结果中复制 id 字段): https://graph.microsoft.com/v1.0/teams/{team-id}/channels
    3. 与频道关联的 Sharepoint 站点(复制 parentReference.driveId 字段(SharePoint 的根目录)和 id 字段(与频道同名的目录)): https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/filesFolder
    4. 频道的 Sharepoint 目录的内容(复制所需文件(或目录)的 id 字段(DriveItem id)): https://graph.microsoft.com/v1.0/drives/{parentReference.driveId}/items/{channel-directory-id}/children
    5. 如果您需要进入子目录,请将上述url中的{channel-directory-id}替换为您要探索的子目录的id,以获得自己的子目录,并根据需要重复。

    您现在可以构建如下网址:https://graph.microsoft.com/v1.0/drives/{parentReference.driveId}/items/{driveitem-id}/workbook/worksheets/My%20Sheet%20Name/range(address='A1:B2')

    【讨论】:

      【解决方案2】:

      在此工作了很长一段时间后,似乎我的权限设置错误。如需将来参考,请转到Microsoft documentation 并查看页面顶部的permissions section

      【讨论】:

      • 您设置了哪些权限才能让您的权限正常工作?
      猜你喜欢
      • 2017-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      • 1970-01-01
      • 2022-01-12
      相关资源
      最近更新 更多