尝试访问 SharePoint 上的 Excel 文件时无法获取 WAC 访问令牌 [英] Could not obtain a WAC Access Token while trying to access excel file on SharePoint
问题描述
我阅读了一些与我遇到的同一问题有关的问题,但没有一个答案有帮助.
I read some of the questions that were asked pertaining to the same issue I'm having, but none of the answers helped.
我正在尝试读取或获取存储在 SharePoint 网站中的 Excel 文件 (.xlsx) 的单元格数据值.我已经授予以下权限,File.Read.All 和 Site.Read.All.
I am trying to read or get the cell data values of an excel file (.xlsx) stored in a SharePoint site. I've already granted the following permissions, File.Read.All and Site.Read.All.
当我尝试在 MS Graph Explorer 上运行以下查询时,我得到拒绝访问".我在查询中填充了 site-id 和 list-id,但未在此处显示.
When I try to run the query below on MS Graph Explorer, I get 'Access Denied'. I have the site-id and list-id populated in my query but not shown here.
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/3/driveItem/workbook/worksheets/usedRange
回复预览
{
"error": {
"code": "AccessDenied",
"message": "Could not obtain a WAC access token.",
"innerError": {
"date": "2021-03-03T17:47:01",
"request-id": "ccb9aa2e-ef69-4834-802c-f71d43ee1b78",
"client-request-id": "c478..."
}
}
}
推荐答案
这让我摸不着头脑,但我终于能够通过 SharePoint 访问和操作我的 excel 文件.我错误地访问了 excel 文件.
This had me scratching my head but I am finally able to access and operate on my excel file over SharePoint. I was accessing the excel file incorrectly.
我使用下面的查询来获取所有站点,包括根级别和子站点:
I used the query below to get all the sites, including root level and sub sites:
https://graph.microsoft.com/v1.0/sites?search=*
因为使用下面没有列出我需要的网站:
as using the one below didn't list the site I needed:
https://graph.microsoft.com/v1.0/sites/root
因为我的 excel 文件位于该站点的文件夹中,所以我需要提供 list-item-id,因为该文件夹是站点的一个项目.然后,我可以将文件夹作为 drive 访问,并使用 root 从文件夹的根目录提供到 excel 文件的路径.最后,对工作簿进行任何需要的操作.
Because my excel file is within a folder on that site, I need to provide the list-item-id as the folder is an item of the site. Then, I am able to access the folder as a drive and use root to provide the path to the excel file from the folder's root directory. Finally, do whatever operation needed to the workbook.
.../v1.0/sites/{site-id}/lists/{list-item-id}/drive/root:/{path-to-file}:/workbook/worksheets/{sheet-name or sheet-id}/usedRange
参考文献:
在 Microsoft Graph 中使用 SharePoint 网站
这篇关于尝试访问 SharePoint 上的 Excel 文件时无法获取 WAC 访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!