2016-09-28 82 views
2

我有一個使用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應用程序中

回答

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

+1

我見過這些教程,看起來像我只是不understan那裏發生了什麼事。我不想兩次授權,我認爲重定向到https:// login.windows.net/common/oauth2/authorize /總是執行強制授權,但看起來情況並非如此。如果應用程序已通過身份驗證,則重定向到此URL將重定向回''redirectUri'跳過整個授權屏幕,所以這正是我一直在尋找的內容 – Archeg