How To Create A Power BI Embed Token

Introduction 

 
In the area of data visualization, Microsoft Power BI is a leading force. In this post, we are going to learn how to generate Embed token to host Power BI reports in any web application. Sometimes it will take hours to figure out how to embed token. Use these steps to do it in an hour.
 
To embed a Power BI report, it must be authorized by Azure AD. In regard to that, we have to create Azure Ad application and give the right permissions. In the case of Power BI, Microsoft created a simple flow to register the app and get a Client ID and Client Secret code. Use this to register application in Azure. A similar screen will come to register the application. For example, I registered the DemoPowerBIApp.
 
 
Select the Application type as a server-side web application and add a redirect URL.
 
 
 
In the permissions part, select all.
 
The next step is to assign the right permissions to the created AD application. For that, login to your Azure portal and go to Azure Active Directory. Select the created app, in my case I selected “DemoPowerBIApp”. Select API permission and click on Grand Admin consent for the application. As a reference, use this image.
 
 
Select Authentication to the left of Navigation and add a redirect URL. This setting is quite important to authorize your client domain to Azure token API. Add a platform select web and add a redirect URL. In our case, it will be already be added as we created an app using the above URL.
 
 
Also, set the Default client Type to yes and save.
 
 
Use the STW source code in our git report to get a token.
 
For testing the application, you can use this URL.
 
Thanks! Happy Programming!!