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
Ameb
Helper I
Helper I

Display report using powerbi-client and react (typescript)

Hello. 

I have been working on a .NET Core application with React.

Server side works fine (tokens generated work on the powerbi javascript demo)

 

 

Tokens from PowerBI Javascript Demo  doesnt work on the client side (react component). Neither the tokens generated from my server.

 

GET https://wabi-north-europe-redirect.analysis.windows.net/metadata/cluster 403 (Forbidden)

 

I have recreated a small application. Here is the component:

import * as React from 'react';
import * as pbi from 'powerbi-client';

export default class App extends React.Component<{}, {}> {
    private powerbi: pbi.service.Service;
    private embedContainer: HTMLDivElement;
    constructor(props: {}) {
        super(props);
        this.powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
    }
    public render() {
        return (
                <div className="embedContainer" powerbi-type="report" style={{'height' : '600px', 'width' : '100%'}} ref={(div) => { if (div) {this.embedContainer = div; }}}/>
        );
    }
    componentDidMount() {
        // console.log(this.props);
        let config = {
            'accessToken': '',
            'embedUrl':  '',
            'id': ''
        };
        console.log(config);
        this.powerbi.embed(this.embedContainer, config);
    }
}

 

Would love to share a repo with the code, but i think is not allowed (my posts are being deleted without reason/ private message)

 

1 ACCEPTED SOLUTION
Ameb
Helper I
Helper I

The property tokenType was missing from the config.

View solution in original post

3 REPLIES 3
Ameb
Helper I
Helper I

The property tokenType was missing from the config.

Hello Ameb,

 

Do you mind sharing working source code or project files? 

I am no longer working on this so can't clean the code properly or give you a detailed or simplified working code, but i uploaded what i had. Hope it helps.

 

https://github.com/Ameb/PBIEmbedded-NetCore-React-Demo

 

Most of my issues with this were the matching between the config used with the embedding API and the way the tokens were generated (since you can actually use an AD bearer token for embedding). 

 

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.