当我尝试使用此Microsoft Graph查询列出sharepoint站点中的所有列表时,它返回401错误 . 但阅读清单工作正常 .
{
"error": {
"code": "unauthenticated",
"message": "Access denied. You do not have permission to perform this action or access this resource.",
"innerError": {
"request-id": "6929864e-9d14-4911-9d7e-d0a29259e05f",
"date": "2017-06-21T21:00:15"
}
}
}
-
不起作用:https://graph.microsoft.com/beta/sites/ / lists
-
工作:https://graph.microsoft.com/beta/sites/ / lists /
谢谢
2 回答
通常,401响应表示服务器验证您的API请求所需的信息要么在请求中丢失,要么存在,但在某种程度上无效 . 我建议你:
1)验证失败的请求中是否存在 Authorization 标头 .
2)如果存在,则验证请求失败的 Authorization 标头的内容是 identical 到成功请求中 Authorization 标头的内容 .
如果您在两个请求中发送完全相同的 Authorization 标头,那么我不希望服务器为操作-B返回403 Forbidden响应 - 而不是401 Unauthorized响应 . )
Update (some additional thoughts)
看起来两个操作都需要这两个访问范围之一:
Sites.Read.All
Sites.ReadWrite.All
您应该验证您在失败请求的
Authorization
标头中指定的令牌是否至少具有这些范围中的一个(尽管如前所述,我'd expect the server to return 403 if you didn'具有适当的访问范围) .此外,如果您在没有用户提供授权的情况下通过OAuth获取了访问令牌,那么此答案中的信息可能会有所帮助:How to use OAuth when there is no user delegation? -- Microsoft Graph API . 在帖子描述的场景中,服务器返回401响应,因为开发人员没有明确获得他们试图执行的操作的管理员同意 .
你可以再试一次吗?这个(https://graph.microsoft.com/beta/sites/ / lists)似乎现在正在运作 .