Owin中针对Power Bi的身份验证

时间:2016-09-28 10:54:23

标签: c# asp.net-mvc azure active-directory powerbi

我使用Azure AD身份验证使用ASP MVC开发了一个应用程序。该应用程序应该将数据发布到Power BI。我试过遵循这个教程:https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-register-a-client-app/,它有效,而且几乎正是我需要的。

问题在于它使用Native App身份验证,而我的应用程序是一个Web应用程序。此外,我的应用程序已经针对Azure AD进行了身份验证,我不想第二次询问用户凭据。

我假设我可以以某种方式从当前的Owin Context获取持有者令牌,并使用它来验证Power BI。这是正确的,我该怎么做?

我的应用是VS模板生成的简单应用,启用了AD身份验证,因此发布任何代码都没有意义。

更新 啊,好吧只是一些细节(如果你需要更多,请告诉我): 登录(由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进行身份验证。我系统中的每个用户都有自己的报告显示在网络应用

1 个答案:

答案 0 :(得分:0)

您应该使用Authenticate your web appAzure Active Directory tenant而不是使用Power BI注册客户端应用。

教程

Authenticate your web app

Azure Active Directory tenant

示例应用

https://github.com/Microsoft/PowerBI-CSharp/tree/master/samples/webforms/get-started-web-app-asp.net