How do I prevent my app from redirecting to Power BI when embedding a protected report in a React application

0 votes
How do I prevent my app from redirecting to Power BI when embedding a protected report in a React application?

I'm embedding a protected Power BI report into a React application but experiencing an issue where users are redirected to Power BI instead of staying within the app. How can I prevent this redirection and ensure seamless embedding? What authentication methods and configurations are required to keep users within the application while viewing the report?
8 hours ago in Power BI by Evanjalin
• 15,820 points
14 views

1 answer to this question.

0 votes

To ensure that your React app will not redirect to Power BI while embedding a protected report, follow these steps:

1. Power BI Embed for Customers and Organizations

For Organizations: Azure AD authentication requires access tokens.

For customers: Use Service Principal authentication in a special workspace.

2. Create an Embed Token

Obtain an Azure AD token using MSAL.js or a backend service, and then call the Power BI REST API to get an embed token.

POST https://api.powerbi.com/v1.0/myorg/reports/{reportId}/GenerateToken

3. Embed Report Correctly in React

Use the Power BI JavaScript SDK (powerbi-client-react):

import { PowerBIEmbed } from 'powerbi-client-react';
import { models } from 'powerbi-client';

<PowerBIEmbed
  embedConfig={{
    type: "report",
    id: "your-report-id",
    embedUrl: "your-embed-url",
    accessToken: "your-access-token",
    tokenType: models.TokenType.Embed,
  }}
  eventHandlers={{
    loaded: () => console.log("Report Loaded"),
    error: (event) => console.error("Embed Error:", event),
  }}
/>

4. Enable Same-Site Authentication

  • Ensure CORS policies allow embedding.
  • Configure your authentication to handle silent token refresh using MSAL.js.


answered 8 hours ago by anonymous
• 15,820 points

Related Questions In Power BI

0 votes
1 answer

How can I retrieve a mapped value from a many-to-one related table in Power BI when using DirectQuery mode?

Get the associated values per multiple linked ...READ MORE

answered Jan 23 in Power BI by pooja
• 14,980 points
48 views
0 votes
1 answer

How do I know who in my organization has a Power BI account?

You can view the Azure Active Directory ...READ MORE

answered Oct 15, 2018 in Power BI by Hannah
• 18,520 points
1,237 views
0 votes
1 answer

How to create a new dashboard by pinning visualizations from a report in Power BI?

Hey, I can show some steps wise steps ...READ MORE

answered Feb 6, 2020 in Power BI by Gitika
• 65,770 points
1,156 views
0 votes
1 answer

I have a web API with basic authorisation and username and password. How do i connect to it in Power BI?

Hey, @There, I found your query is quite ...READ MORE

answered Oct 29, 2020 in Power BI by Gitika
• 65,770 points
3,884 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,497 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,130 points
2,855 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,632 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Yes using Power BI REST API to ...READ MORE

answered Sep 18, 2018 in Power BI by Kalgi
• 52,350 points
1,771 views
0 votes
1 answer

How do I configure a read-only user for PostgreSQL in Power BI to maintain security?

To configure a read-only user for PostgreSQL ...READ MORE

answered 8 hours ago in Power BI by anonymous
• 15,820 points
10 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP