Embedding Basics

ali-hamud edited this page Jun 13, 2017 · 17 revisions

Power BI reports can now be embedded into your own applications. There are two different tokens for embedding depending on who owns the reports (e.g. Application or User).

User owns the data

If you are developing an application where the application users have Power BI accounts, you are in the right section. In this scenario, users of your application sign in using their Power BI accounts. This gives you Access Token which you should use to access to their data and embed their reports, dashboards and tiles. In this scenario, set TokenType to "AAD".

// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;

var embedConfiguration = {
	type: 'report',
	id: '5dac7a4a-4452-46b3-99f6-a25915e0fe55',
	embedUrl: 'https://app.powerbi.com/reportEmbed',
	tokenType: models.TokenType.Aad,
	accessToken: 'e4...rf'
};

var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);

Application owns the data

If you are developing an application which embeds reports you own, you are in the right section. In this scenario, you have to create Power BI account, and upload your reports to the created account. Then, you can call Power BI APIs to generate Embed Token for reports, dashboards or tiles you want to embed. For more information about embedding entities using Embed Tokens, please visit Embed Token Documentation. In this scenario, set TokenType to "Embed". once you have the embed token, use the following code to embed:

// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;

var embedConfiguration = {
	type: 'report',
	id: '5dac7a4a-4452-46b3-99f6-a25915e0fe55',
	embedUrl: 'https://app.powerbi.com/reportEmbed',
	tokenType: models.TokenType.Embed,
	accessToken: 'h4...rf'
};

var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.