Understanding the different embedding solutions

Embedding Power BI items (such as reports, dashboards and Q&A) into your application allows you to integrate stunning, fully interactive analytics without having to build your own data visualizations and controls from scratch. The Power BI analytics that you embed can either present data that your app owns through your own Power BI account, or data that the user owns through their Power BI accounts.

Application scenarios

There are two different scenarios for embedding a Power BI report in an application.

  • Embed for your organization (also known as user owns data): The application allows you to integrate data, reports, dashboards, and tiles that are accessible to users in your organization when they sign in using their own Power BI accounts. In this type of application, the users own the data that you embed.
  • Embed for your customers (also known as app owns data): The application presents the data, reports, dashboards, or tiles that you uploaded to your own Power BI account. In this type of application, you are using your own account, so your application owns the data for your customers. Your customers don't need their own Power BI account.

The application scenario that you use determines how you retrieve an access token that allows you to access data and embed content in your application.

The type of content that you embed is specified by the value of theembedUrl parameter. To retrieve an embed URL for a particular type of content, call the corresponding Power BI REST API. For example, call Get Reports to retrieve the embed URL for embedding a report.

The following sections show you how to retrieve an access token and embed a report for each of these application scenarios.

Embed for your organization

In this scenario, users of your application sign in using their Power BI accounts. This gives you the access token for accessing their data and embedding their reports, dashboards, and tiles.

In the embedConfiguration, set tokenType to TokenType.Aad.

// Get models so you can use the TokenType enum.
let models = window['powerbi-client'].models;

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

let reportContainer = $('#reportContainer')[0];
let report = powerbi.embed(reportContainer, embedConfiguration);

Embed for your customers

In this scenario, you create a dedicated identity that has access to all the Power BI items. Then, you generate an Embed Token for the reports, dashboards, or tiles that you want to embed by calling the Power BI REST API Embed Token. Once you have an embed token, use the following code to embed the report:

In the embedConfiguration, set tokenType to TokenType.Embed.

// Get models so you can use the TokenType enum.
let models = window['powerbi-client'].models;

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

let reportContainer = $('#reportContainer')[0];
let report = powerbi.embed(reportContainer, embedConfiguration);