cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jgermain Frequent Visitor
Frequent 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
Moderator Eric_Zhang
Moderator

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


@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>

 

 

jgermain Frequent Visitor
Frequent Visitor

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

@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
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)