我正在尝试编写嵌入了一些Power BI报告的网络应用。数据是内部部署的,因此我无法使用新的可用解决方案(Power BI Embedded)。现在使用旧方法(https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-a-power-bi-tile-or-report/)的不便之处在于,网页的使用者需要是一个Power BI用户,需要登录才能使Web应用程序最终获得身份验证令牌(有需要在之前发生的几页重定向)。 所以我的问题是,有没有办法以编程方式进行Power BI登录?所以这样我就可以使用一个Power BI帐户来获取内容。
答案 0 :(得分:1)
我也在那里做实验, 这个帖子帮助了我(见第8条):
基本上:
POST请求: https://login.microsoftonline.com/common/oauth2/token
Body,form-url-encoded:
然后你直接获得令牌。
也可以考虑如下所述的安全问题:http://www.cloudidentity.com/blog/2014/07/08/using-adal-net-to-authenticate-users-via-usernamepassword/在"何时不使用此功能"
答案 1 :(得分:0)
我做同样的事只是一个巧合。实际上,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}
}