0

I have created a report with mock data in PowerBI (free version), which I would like to embed onto a local react application for testing purposes, but for some reason I cannot make it work.

My main problem is that I cannot find a way to get a valid access token.

First I tried to get the personal access token from the console (ctrl shift c -> console -> run powerBIAccessToken) but unfortunately the embed does not load.

Then I tried to get it through the public API, but when I use the group id and report id I get the error Calling group APIs not permitted for personal workspace.

This is my app.js code

import logo from './logo.svg';
import './App.css';
import { PowerBIEmbed } from 'powerbi-client-react';
import { models } from 'powerbi-client';

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <img src={logo} className="App-logo" alt="logo" />
                <PowerBIEmbed
                    embedConfig={{
                        type: 'report',   // Supported types: report, dashboard, tile, visual and qna
                        id: process.env.REPORT_ID,
                        embedUrl: process.env.EMBED_URL,
                        accessToken: process.env.ACCESS_TOKEN,
                        tokenType: models.TokenType.Aad,
                        settings: {
                            panes: {
                                filters: {
                                    expanded: false,
                                    visible: true
                                }
                            },
                        }
                    }}

                    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;
                    }}
                />
            </header>
        </div>
    );
}

export default App;

1 Answer 1

0

Embed should work even if we get the accessToken from the console using copy(powerBIAccessToken) which will be of type TokenType.Aad.

If you want to generate EmbedToken using REST API, use this Generate Token REST API, which will be of type TokenType.Embed.

If you want to view an Embedded report, the report should be hosted in Power BI workspace that has premium capacity. Refer to this MSFT documentation for more information

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.