【发布时间】:2020-01-31 05:13:52
【问题描述】:
我正在尝试使用来自https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part 的模板将应用程序添加到我们的 SharePoint Online 网站,当我们部署到 SharePoint 并将应用程序/Web 部件添加到测试 SharePoint 网站时,我们收到以下错误。我们使用 TypeScript 作为模板使用。
有没有其他人遇到过这个问题或者知道去哪里找这个问题?
找到 [object Object] 驱动程序显示外部错误:错误:AADSTS500011:在名为 7018324c-9efd-4880-809d-b2e6bb1606b6 的租户中找不到名为 https://driverdisplayexternal.azurewebsites.net 的资源主体。如果租户管理员未安装应用程序或租户中的任何用户未同意此应用程序,则可能会发生这种情况。您可能已将身份验证请求发送给错误的租户。跟踪 ID:358b22eb-cd2c-4091-b592-5a57cbc21d00 相关 ID:ec96d656-1a36-42e2-a2b9-3ff78efc1e2e 时间戳:2019-10-01 16:26:06Z
我们添加了对我们自己的客户的调用,如下所示。我们不确定为什么找不到资源主体。租户 ID 的匹配项似乎已正确设置以进行身份验证。
HelloWorldWebPart.ts
...
this.context.aadHttpClientFactory
.getClient('https://driverdisplayexternal.azurewebsites.net')
.then((client: AadHttpClient): void => {
client
.get('https://driverdisplayexternal.azurewebsites.net/api/values', AadHttpClient.configurations.v1)
.then((response: HttpClientResponse): Promise < Order[] > => {
this.domElement.innerHTML += 'Received a response from Driver Display External: ' + response;
return response.json();
})
.catch(error => {
this.domElement.innerHTML += 'Driver Display External Error: ' + error;
console.error(error);
});
});
...
package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "helloworld-webpart-client-side-solution",
"id": "**ID**",
"version": "4.1.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false,
"webApiPermissionRequests": [
{
"resource": "DriverDisplayExternal",
"scope": "User.Read.All"
}
]
},
"paths": {
"zippedPackage": "solution/helloworld-webpart.sppkg"
}
}
非常感谢您对问题所在位置的任何帮助或指导。提前致谢!
【问题讨论】:
-
如果要调用受Azure AD保护的服务,资源url必须是Azure AD应用的app id url。更多详情请参考stackoverflow.com/questions/36059051/…
-
@JimXu 我试过了,不幸的是没有用。谢谢你的建议。
-
能否告诉我是否可以从邮递员等其他工具调用该api?
-
是的,我们可以使用邮递员。我的同事创建了一个新应用程序,它以不同的方式获取我们需要的东西,但遗憾的是我们仍然没有解决这个问题。
-
你是用 Azure AD 保护你的 api 吗?如果是这样,您能否告诉我您用于保护 API 的 AD 应用程序的租户和 SharePoint 的租户是否相同?
标签: javascript typescript azure azure-active-directory sharepoint-online