php - "Access denied"Microsoft Graph 制作文件夹时

标签 php sharepoint microsoft-graph-api microsoft-graph-sdks

尝试在 SharePoint 站点中创建文件夹时出现以下错误:

{
  "error": {
    "code": "accessDenied",
    "message": "Access denied",
    "innerError": {
      "request-id": "61d3b5aa-857e-4ee2-9d0d-51d235ca7c5f",
      "date": "2020-05-18T06:31:54"
    }
  }
}

注意事项:

  1. 使用 Microsoft Graph Explorer 时,请求有效。
  2. 对 Graph 端点的其他请求有效。
  3. 我使用 msgraph-sdk-php 发出请求。
  4. 这通常与权限有关,但我的用户具有以下权限 天蓝色的权限设置:

    Sites.Manage.All    Delegated.
    Sites.Read.All      Delegated.
    Sites.ReadWrite.All Delegated.
    
  5. 在 my.env 中我有以下权限:

    OAUTH_SCOPES='openid profile offline_access user.read calendars.readwrite mail.readwrite mail.send'
    
  6. 网址:

     https://login.microsoftonline.com/common/oauth2/v2.0/authorize?%20state={someState}%20&scope=openid%20profile%20offline_access%20user.read%20calendars.readwrite%20mail.readwrite%20mail.send%20&response_type=code&approval_prompt=auto&redirect_uri=http://localhost:8080/office365/token/store%20&client_id={myclientId}
    

是什么导致了这里的错误?

最佳答案

您需要在 OAUTH_SCOPES 变量中添加一个或多个所需范围(Sites.Read.All、Sites.ReadWrite.All、Sites.Manage.All):

OAUTH_SCOPES='Sites.Manage.All ...'

因此您的授权 URL 是这样构建的:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope=Sites.Manage.All ...&client_id=...

PS:上述范围均不需要 admin consent .

关于php - "Access denied"Microsoft Graph 制作文件夹时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61863841/

相关文章:

c# - 使用别名地址过滤用户 - MS Graph

Azure AD token 颁发端点不返回 "scope"参数

php - 使用 Facebook Graph API 获取纽约市的餐厅列表

sharepoint - 更新 SharePoint 作业的进度

php - PDO 准备好的语句有多安全

javascript - SharePoint - 在 GetListItems SOAP 调用上执行用户查找

python - 如何使用 Microsoft Graph 覆盖上传到 SharePoint 的文件

c# - 如何使用 Microsoft Graph API 获取用户所属的组名?

php 和 MySQL 只显示第一个单词

php - PHP错误: Undefined offset error within foreach loop