在网站集应用程序目录中使用 Web 应用程序权限
Use web app permissions in Site Collection app catalog
我创建了一个 spfx 包,其中包含一个从 MS Graph 读取的 Web 部件。该解决方案在 package-solution.json:
中请求以下权限
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All,Directory.ReadWrite.All"
}
]
当我将解决方案部署到租户应用程序目录时,这工作正常。当我将解决方案部署到网站集应用程序目录时,它会毫无错误地部署并创建 API 访问请求(我批准)。但是在使用 MSGraphClient 时,webpart 抛出以下错误:
Uncaught (in promise) Error: Error making HttpClient request in queryable [403] Forbidden ::> {"error":{"code":"Authorization_RequestDenied","message":"Insufficient privileges to complete the operation.","innerError":{"date":"2021-05-20T19:40:49","request-id":"82b80ddb-...","client-request-id":"82b80ddb-..."}}}
是否不支持这种情况,或者我是否遗漏了任何必需的步骤?
webApiPermissionRequests 是一组 webApiPermissionRequest 项。每一项都定义了资源和权限请求的范围。
将您的权限更改为以下内容
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.ReadWrite.All"
},
{
"resource": "Microsoft Graph",
"scope": "Directory.ReadWrite.All"
}
]
此外,在您将解决方案部署到租户应用目录之后。您需要在 SharePoint 管理中心批准请求的 Microsoft Graph 权限:https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis#approve-the-requested-microsoft-graph-permissions
我创建了一个 spfx 包,其中包含一个从 MS Graph 读取的 Web 部件。该解决方案在 package-solution.json:
中请求以下权限"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All,Directory.ReadWrite.All"
}
]
当我将解决方案部署到租户应用程序目录时,这工作正常。当我将解决方案部署到网站集应用程序目录时,它会毫无错误地部署并创建 API 访问请求(我批准)。但是在使用 MSGraphClient 时,webpart 抛出以下错误:
Uncaught (in promise) Error: Error making HttpClient request in queryable [403] Forbidden ::> {"error":{"code":"Authorization_RequestDenied","message":"Insufficient privileges to complete the operation.","innerError":{"date":"2021-05-20T19:40:49","request-id":"82b80ddb-...","client-request-id":"82b80ddb-..."}}}
是否不支持这种情况,或者我是否遗漏了任何必需的步骤?
webApiPermissionRequests 是一组 webApiPermissionRequest 项。每一项都定义了资源和权限请求的范围。
将您的权限更改为以下内容
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.ReadWrite.All"
},
{
"resource": "Microsoft Graph",
"scope": "Directory.ReadWrite.All"
}
]
此外,在您将解决方案部署到租户应用目录之后。您需要在 SharePoint 管理中心批准请求的 Microsoft Graph 权限:https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis#approve-the-requested-microsoft-graph-permissions