Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
vai1sf
Regular Visitor

Embed report using react-powerbi-client ends with 403

Hello, 

 

I'm new to PowerBi and I'm the React developer who consumes the PowerBI report, developed by other team. My goal is to embed a report into our portal and filter it.

I'm granted view permissions (I can see and filter the report in PowerBi) and I have Power BI Pro License.
I've followed this steps https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-embed-secure#how-to-embed-power...  and successfully embeded the report into iFrame in our portal. 

There's a downside that the customer should always login into PowerBi in order to see the portal. That's why I would like to try embeding the portal with react-powerbi-client. I'm doing exactly the same as it's written in the demo, also tried the way it's implemented in the Microsoft Power BI Embedded Analytics Playground (Preview) demo through the report.

 

The problem which I hit is that I receive 403 Forbidden from 'https://api.powerbi.com/metadata/cluster' call.
A few things makes me suspicious in the headers of the call I made:
1) I have 

Authorization: EmbedToken Bearer <my_access_token> 

 while in the playground the "EmbedToken" string is missing

2) I have

X-Powerbi-Hostenv: Embed for Customers

 while in the playground the value is "Embed for Organization" and that's what I want.

 

This is my configration for the PowerBIEmbed component:

{
type: 'report',
embedUrl: baseUrl,
tokenType: models.TokenType.Embed,
accessToken: undefined, //after successfull aquire the token is set
permissions: models.Permissions.All,
}


P.S. In the Azure portal we granted permissions to the PowerBi services, following this steps: https://learn.microsoft.com/en-us/power-bi/developer/embedded/change-permissions?tabs=Azure 

 

Any guides what am I missing or links to documentation how to solve 403 Forbidden through PowerBiEmbed react component would be helpful! 

Best regards,

Iva

1 ACCEPTED SOLUTION
vai1sf
Regular Visitor

UPDATE: Incorrect embedtoken type is used, should be 

models.TokenType.Aad

 

View solution in original post

4 REPLIES 4
Hari000
New Member

I am also facing the same issue, I am using App Owns Data concept,

Hari000_0-1734328275794.pngHari000_1-1734328280604.png

 

I am following this blog post to generte the embed token
https://medium.com/globant/how-to-embed-a-power-bi-report-in-react-f27e975e0a

I am able to generate the token but the report is not showing in my front-end, and this is my reactjs code 


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

function Dashboard() {
    return (
        <div>
            <PowerBIEmbed
                embedConfig={{
                    type: 'report',
                    id: 'xxxxxxxxxxxx',
                    embedUrl: "my embed url",
                    accessToken: "my access token",
                    tokenType: models.TokenType.Aad,
                    settings: {
                        panes: {
                            filters: {
                                expanded: false,
                                visible: false
                            },
                        },
                        customContextMenu: false,
                    }
                }}

                eventHandlers={
                    new Map([
                        ['loaded', function () { console.log('Report loaded'); }],
                        ['rendered', function () { console.log('Report rendered'); }],
                        ['error', function (event) { console.log(event.detail); }]
                    ])
                }

                cssClassName={"Embed-container"}

                getEmbeddedComponent={(embeddedReport) => {
                    window.report = embeddedReport;
                }}
            />
        </div>
    );
}

export default Dashboard;
vai1sf
Regular Visitor

UPDATE: Incorrect embedtoken type is used, should be 

models.TokenType.Aad

 

Anonymous
Not applicable

HI @vai1sf,

Perhaps you can take a look the official document about embed with react app if help with your scenario:

How to embed a Power BI item in a React app | Microsoft Learn

Regards,

Xiaoxin Sheng

 Hi @Anonymous ,

Thanks for your suggestion! This is exactly what I'm doing.
Can you please guide me what are the prerequisite configurations/permissions of the PowerBi report itself in order to be embeded within the application?

Best regards,

Iva

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.