繁体   English   中英

Power BI - 以编程方式登录

[英]Power BI - Programmatically sign in

我正在尝试编写一个嵌入了一些 Power BI 报告的 Web 应用程序。 数据在本地,因此我无法使用可用的新解决方案(Power BI Embedded)。 现在使用旧方法( https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-a-power-bi-tile-or-report/ )的不便在于web 页面需要是 Power BI 用户,该用户需要登录才能让 Web 应用最终获得身份验证令牌(之前需要进行几次页面重定向)。 所以我的问题是,有没有办法以编程方式进行 Power BI 登录? 这样我就可以只使用一个 Power BI 帐户来获取内容。

我也在那里进行实验,这个线程帮助我解决了这个问题(见帖子 #8):

http://community.powerbi.com/t5/Developer/How-to-use-Power-BI-Rest-API-without-GUI-authentication-redirect/mp/14218#

基本上:

POST 请求到: https : //login.microsoftonline.com/common/oauth2/token

正文,表单 url 编码:

  • grant_type:“密码”
  • 范围:“openid”
  • 资源:“ https://analysis.windows.net/powerbi/api
  • client_id:您的客户 ID
  • client_secret:您的客户机密
  • 用户名:那个用户名
  • 密码:那个用户名密码

然后你直接得到令牌。

此外,考虑如下所述的安全问题可能会很好: http : //www.cloudidentity.com/blog/2014/07/08/using-adal-net-to-authenticate-users-via-usernamepassword/在“When不要使用此功能”

我也在做同样的事情,这只是巧合。 实际上,Power BI 提供了一个 Rest API 来很容易地做到这一点。 您需要在 Azure 门户注册一个应用程序,该应用程序将为您提供客户端 ID 和客户端机密。 现在您可以使用其余 API 和这些详细信息。

POST: https://login.microsoftonline.com/common/oauth2/token

在正文中,您需要发送这些详细信息,在标题中,您需要设置Content type : application/x-www-form-urlencoded

data: {
    grant_type: password
    scope: openid
    resource: https://analysis.windows.net/powerbi/api
    client_id: {Client ID}
    username: {PBI Account Username}
    password: {PBI Account Username}
    client_secret: {Enter client secret here}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM