We’re pretty stoked to have a new version of our web application sample out on GitHub. We took the original sample and paired it down significantly to focus on those elements that are critical to understanding how to call the Power BI REST API from a web application. You’ll find the overall flow is simpler and the critical authentication steps are easier to follow.
You can get it on GitHub right now to get started.
We see that for many developers who work with AAD for the first time the authentication workflow is the hardest part of making API calls to Power BI. The root is that most folks are not familiar with the full OAuth 2.0 authentication workflow. So the Power BI web sample shows you how to register a Power BI ASP.NET web app in Azure AD. It walks you through the authentication workflow with Azure AD, including how to create a query string to authenticate with Azure AD. Then it shows how to use Response.Redirect() to redirect to the Azure AD authentication service. It gets the authentication code sent from Azure AD, and uses it to get the authentication token from the authentication code. With all that done, it shows you how to call the Power BI REST API using the Azure AD access token.
Check out the documentation available on MSDN as well.