Owin中对Power Bi的验证
问题描述:
我有一个使用Azure AD验证的ASP MVC开发的应用程序。此应用程序应该将数据发布到Power BI。我试图按照这个教程:https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-register-a-client-app/,它的工作原理,它几乎正是我需要的。Owin中对Power Bi的验证
问题是它使用本机应用程序认证,而我的应用程序是一个Web应用程序。此外,我的应用程序已经针对Azure AD进行了身份验证,并且我不想再次询问用户凭据。
我假设我可以以某种方式从当前的Owin上下文中获取持有者令牌,并使用它来对Power BI进行身份验证。这是正确的,我该怎么做?
我的应用程序是通过启用AD身份验证的VS模板生成的简单应用程序,因此无法发布任何代码。
更新 啊,OK只是一点点细节(让我知道如果你需要更多): 签名的(由VS生成)是:
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
认证类型为"OpenIdConnect"
Startup.Auth.cs
是:
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri
});
还有一件事,我不确定它从帖子中清楚。我的目标是使用当前登录的用户凭证对PowerBi进行身份验证。我的系统中的每个用户都将拥有自己的报告以显示在Web应用程序中
答
您应该使用Authenticate your web app
或Azure Active Directory tenant
而不是使用Power BI注册客户端应用程序。
教程
示例应用程序
https://github.com/Microsoft/PowerBI-CSharp/tree/master/samples/webforms/get-started-web-app-asp.net
我见过这些教程,看起来像我只是不understan那里发生了什么事。我不想两次授权,我认为重定向到https:// login.windows.net/common/oauth2/authorize /总是执行强制授权,但看起来情况并非如此。如果应用程序已通过身份验证,则重定向到此URL将重定向回''redirectUri'跳过整个授权屏幕,所以这正是我一直在寻找的内容 – Archeg