c# - 将 PowerBI 仪表板/报表嵌入 Web 应用程序
问题描述
我正在尝试将 Power BI Dash Board 报告嵌入到 Web 应用程序中。
1) 我已经使用此 Microsoft 链接及其来自 github https://docs.microsoft.com/en-us/power-bi/developer/embed-sample-for-your-organization的示例应用程序配置了应用程序。
2)我也尝试使用此文档进行配置https://bitbucket.org/omnistream/powerbi-api-example \
我正在使用我的公司电子邮件 ID /password 访问端点。以下是详细信息。我拥有仪表板报告的管理员权限,并且拥有 Power BI pro 用户帐户。
发布端点:https ://login.microsoftonline.com/common/oauth2/token
请求标头:用户代理:提琴手主机:login.windows.net 内容类型:application/x-www-form-urlencoded 内容长度:xxx
请求正文:grant_type=password&scope=openid&username=myUserName@mycompany.com&password=MyPassword&client_id=XXXXX&resource= https://analysis.windows.net/powerbi/api&client_secret=XXXXX
它抛出以下错误:error_description=AADSTS70002:验证凭据时出错。AADSTS50126:用户名或密码无效 跟踪 ID:c13c59dc-79e2-4169-bae2-06c402310100 相关 ID:a747a226-362a-45aa-956a-122629fa9863 时间戳:2018-08-06 21:27:59Z
我需要单独配置或创建 Master Power BI 帐户吗?
或者如果我的公司网络干扰 Post 请求以屏蔽用户 ID/密码,是否有任何工具可以帮助我跟踪此网络问题?
解决方案
即使绕过公司代理以获取凭据,它也无法正常工作。最后,我向 Microsoft 记录了票证,并且能够使其仅适用于其中一个选项,即本机应用程序。下面是步骤
1) 从这里下载“App 拥有数据”应用程序。并在 Azure 门户中将您的 power Bi 应用程序注册为应用程序类型的“本机应用程序”。有关配置 PowerBI 应用程序网页嵌入的详细信息,请访问相关链接 #1。
2) 打开项目并使用 NUget 包管理器导入所有需要的 Dll。
3) 在项目中使用这些值配置 cloud.config。
<appSettings>
<add key="authorityUrl" value="https://login.microsoftonline.com/common/oauth2/authorize/" />
<add key="resourceUrl" value="https://analysis.windows.net/powerbi/api" />
<add key="apiUrl" value="https://api.powerbi.com/" />
<add key="embedUrlBase" value="https://app.powerbi.com/v1.0/myorg/" />
</appSettings>
4) 在项目中使用这些值配置您的 web.config 文件。
<appSettings file="Cloud.config">
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="applicationId" value="xxxxxxx-xxxx-xxxx-xxxx-xxxxxx" /> <!--For PowerBI Native application ID-->
<add key="workspaceId" value="xxxxxxx-xxxx-xxxx-xxxx-xxxxxx" />
<!-- The id of the report to embed. If empty, will use the first report in group -->
<add key="reportId" value="xxxxxxx-xxxx-xxxx-xxxx-xxxxxx" />
<!-- Note: Do NOT leave your credentials on code. Save them in secure place. -->
<add key="pbiUsername" value="XXXXXXXXX@yourcompany.com" />
<add key="pbiPassword" value="xxxxxxxx" />
</appSettings>
5) 在 Power BI 网站上发布您的报告,创建仪表板,在上面的 web.config 设置中填写报告 ID 和工作空间 ID。
6) 执行应用程序。它应该适用于嵌入报告、仪表板和磁贴类型。
推荐阅读
- apache-spark - DROP TABLE IF EXISTS/CREATE TABLE IF NOT EXISTS 不适用于 SparkSQL
- cucumber - BDD+Cucumber+watir 框架中元素定位器的单独文件
- spring - 通过spring cloud数据流中的流部署时无法向任务添加多个参数
- sql - 在 COALESCE (SQL) 中重写 CASE
- python - 在字典中设置顺序
- vim - 大括号内部内容的范围在 Vim 中如何工作?
- google-chrome-extension - chrome.runtime.onMessage 未收到消息
- scala - 用于 API 调用的 Spark 中并行执行的 Spark 时间
- php - 使用 json decode 获取一些数据
- python - 从另一个 DataFrame 的索引列表中提取 DataFrame