【问题标题】:Embedding PowerBI Dash Board/Report into Web application将 Power BI 仪表板/报表嵌入 Web 应用程序
【发布时间】:2018-08-07 04:31:49
【问题描述】:

我正在尝试将 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 内容类型:应用程序/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/密码,是否有任何工具可以帮助我跟踪此网络问题?

【问题讨论】:

  • 您是否将您的域包含在 MyUserName 中(即 MyUserName@example.com)。您是否通过 URI 转义了您的用户名/密码?
  • 它的域名。更新帖子以避免混淆。
  • 就您发送的请求而言,对我来说一切都很好(与我的工作配置的唯一区别是您在 POST 端点的末尾缺少/)。您可能没有授权应用程序 (client_id) 访问您的用户 (myUserName@mycompany.com) 数据。您可以通过 azure 管理门户或使用其中一种交互式身份验证流程(这将弹出一个请求权限的复选框)来执行此操作。

标签: c# powerbi


【解决方案1】:

即使绕过公司代理以获取凭据,它也无法正常工作。 最后,我向 Microsoft 记录了票证,并使其仅适用于其中一个选项,即本机应用程序。下面是步骤

1) 从here 下载“应用拥有数据”应用。并在 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) 执行应用程序。它应该适用于嵌入报告、仪表板和磁贴类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-18
    • 1970-01-01
    • 2020-07-26
    • 2020-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多