简体   繁体   English

使用Power BI在Web App中进行持久身份验证

[英]Persist Authentication in Web App with Power BI

I have a web app that is using the Power BI Web API to display some dashboard data, inside another application. 我有一个Web应用程序,该应用程序使用Power BI Web API在另一个应用程序内部显示一些仪表板数据。 I have followed the authentication examples on GitHub, and can authenticate and query the API. 我已遵循GitHub上的身份验证示例,并且可以身份验证和查询API。

HOWEVER, all of the examples store the returned tokens in temporary storage (eg session), which means that the user has to re-authenticate the application every time they visit (or the app pool restarts). 但是,所有示例都将返回的令牌存储在临时存储区(例如会话)中,这意味着用户每次访问时都必须重新认证应用程序(或应用程序池重新启动)。

Ideally, I want to authenticate the web app when it's set up (using a set of credentials set up just for the app), and then have the web app continue to use the same credentials, without the site users having to log back in to Power BI again (as many of the users of the web app do not have direct Power BI access). 理想情况下,我想在设置Web应用程序时对其进行身份验证(使用仅为该应用程序设置的一组凭据),然后让该Web应用程序继续使用相同的凭据,而无需网站用户重新登录再次使用Power BI(因为许多Web应用程序用户没有直接的Power BI访问权限)。

Is this possible? 这可能吗? If so, how might I go about it? 如果是这样,我该怎么办? All of the examples I can find are such that you have to re-authenticate every time you access the API. 我可以找到的所有示例都使得您每次访问API时都必须重新进行身份验证。 I suspect because I don't know the correct terminology here (this is my first time using the AAD services and authentication) I may be missing something obvious. 我怀疑是因为我不知道这里的正确术语(这是我第一次使用AAD服务和身份验证),我可能缺少明显的东西。

To do what you want, you need to securely store the refresh token. 要执行您想要的操作,您需要安全地存储刷新令牌。 The call to get the initial token should return both the accessToken (that expires within 1hr usually) and a refreshToken that you can use to get new accessToken. 调用以获取初始令牌应返回accessToken(通常在1小时内到期)和refreshToken(可用于获取新的accessToken)。 The refreshToken is usually valid for 90 days, so your access is not indefinitely. refreshToken通常有效期为90天,因此您的访问权限不是无限的。 There's documentation on MSDN for how to do that: https://msdn.microsoft.com/en-us/library/ff752395.aspx 在MSDN上有有关如何执行此操作的文档: https : //msdn.microsoft.com/zh-cn/library/ff752395.aspx

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

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