cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
JimboJonesJr Visitor
Visitor

Not possible receive Power BI report in Webapplication with Access Token

Hello,

 

I have a Node.js script, which returns the access token for a Power BI user. The result I get is actual an Access Token. But when I try to embed my report with the given access token, the report fails to load.

 

So I went to the API examples and copied the Access Token from the example into my Power BI web application and it is working (for a short time until the token has expired).

 

So how do I get the same access token as the one in the API examples?

 

Here is my code:

 

Client:

var embedConfiguration = {
                type: 'report',
                id: '...',
                //for Power BI Embedded
                embedUrl: 'https: //app.powerbi.com/reportEmbed?reportId=...' ,
                tokeType: models.TokenType.Aad,
                accessToken: accessToken
            };

            var element = document.body;

            report = powerbi.embed(elementembedConfiguration);
 
Server:
context.acquireTokenWithClientCredentials(
    resource,
    clientId,
    clientSecret,
    (errtokenResponse=> {
      if (err) {
        console.log(`Token generation failed due to ${err}`);
        return;
      } else {
        console.dir(tokenResponse, { depth: nullcolors: true });
        client_res.send(tokenResponse.accessToken);
      }
    }
  );
 
The Code is working. Just the access token received from my node.js script is not working for my frontend implementation.

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors (Last 30 Days)