【发布时间】:2018-12-20 15:08:53
【问题描述】:
我正在尝试在打字稿应用程序中显示 power bi 报告。
我已成功从 AAD 获得访问令牌,实际上可以通过 power bi rest api 使用它。我希望能够使用 PowerBi-Javascript,以保持清洁并能够应用过滤器。但我每次调用https://api.powerbi.com/powerbi/globalservice/v201606/clusterdetails 时都会收到 403 错误,说“TokenExpired”——即使令牌是新生成的并且应该至少在一个小时内有效。
嵌入报告的代码如下所示:
private embedReport(accessToken: string): powerBiClient.Embed {
const element = this.getDisplayElement();
const reportId = this.getReportId();
const config = {
type: 'report',
id: reportId,
tokenType: powerBiClient.models.TokenType.Aad,
accessToken: accessToken
};
return this.powerBiService.embed(element, config);
getDisplayElement 返回相应的 HTMLElement,getReportId 是要显示的报告的 id,powerBiClient 是 powerbi-javascript 导入,powerBiService 是 powerBiClient.service.Service 的一个实例。
我已尝试使用我拥有的报告以及组中的报告(将 groupId 添加到配置)。
我该如何解决这个错误?
【问题讨论】:
-
如果您尝试做的不仅仅是嵌入报告,那么问题中并不清楚。这个 clusterdetails API 是什么?我以前从未见过它,但能够毫无问题地嵌入报告和单独的可视化。
标签: typescript powerbi powerbi-embedded