Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jgermain
Regular Visitor

Authorization and Access Code workflow for ASP.NET MVC using PowerBI.com

I'm developing a web app that will render embedded reports

* using PowerBI.com, NOT Azure Embedded
* ASP.NET MVC5 web application
* using powerbi javascript api
* intranet application using on-premise Integrated Windows Authentication
* Must support SSO
* all users will be Pro users

Trying to follow this ASP.NET sample (authenticate a web app) and translate to MVC5 however I can't get things to work.

* When user logs into my app (IWA)
* Get Authorization Code from AAD - this returns an HTML login page markup. Can't I use something in Microsoft.IdentityModel.Clients.ActiveDirectory for this?
* Get AAD AccessToken using code returned from above step to call AuthenticationContext.AcquireTokenByAuthorizationCode
* pass access token to view
* view uses token to initialize report via powerbi javascript api following steps here for PowerBI.com

 

Any help or insights on this would be greatly appreciated.

 

2 REPLIES 2
Eric_Zhang
Employee
Employee


@jgermain wrote:

I'm developing a web app that will render embedded reports

* using PowerBI.com, NOT Azure Embedded
* ASP.NET MVC5 web application
* using powerbi javascript api
* intranet application using on-premise Integrated Windows Authentication
* Must support SSO
* all users will be Pro users

Trying to follow this ASP.NET sample (authenticate a web app) and translate to MVC5 however I can't get things to work.

* When user logs into my app (IWA)
* Get Authorization Code from AAD - this returns an HTML login page markup. Can't I use something in Microsoft.IdentityModel.Clients.ActiveDirectory for this?
* Get AAD AccessToken using code returned from above step to call AuthenticationContext.AcquireTokenByAuthorizationCode
* pass access token to view
* view uses token to initialize report via powerbi javascript api following steps here for PowerBI.com

 

Any help or insights on this would be greatly appreciated.


@jgermain

The demo on github from your link actually uses the name space Microsoft.IdentityModel.Clients.ActiveDirectory. What is your concern on this?

 

I don't know about MVC5, however embeding a report from Power BI.com can be as easy as using a static HTML. You just need to get the access token from backend.

<html>

 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script>

<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"></script>
 
<script type="text/javascript">
window.onload = function () {  
 

var embedConfiguration = {
    type: 'report',
    accessToken: 'eyJ0eX....your token here',
    embedUrl: 'https://app.powerbi.com/reportEmbed?reportId=8067fc7f-06axxxxxxxxxxxxxx' 

}; 
 

var $reportContainer = $('#reportContainer');
 
var report = powerbi.embedNew($reportContainer.get(0), embedConfiguration);
 
}
</script>

<div id="reportContainer" ></div>

</html>

 

 

@Eric_Zhang

The issue is not with how to embed using javascript api once I have an access token. Rather, it's with obtaining the authorization code and/or access code from AAD after having successfully logged into my MVC5 intranet app via integrated windows authentication. In essence, I've authenticated against my local AD, but it's unclear how that SSO experience is carried through to AAD when requesting the authorization code or access token.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors