Forum Discussion

calm1kov's avatar
calm1kov
Regular Visitor
9 years ago

Dashboard embed. Requests with 401

 

Hi,

 

 

I've successfully embeded dathboard in web app for non power-bi users.

 

1. Retrieved access token by password grant type:

 

 

POST /common/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded

grant_type=password&[email protected]&password=123456&client_id=asd123-asd345-asd456&resource=https://analysis.windows.net/powerbi/api

 

 

2. Retrieved dashboard token

 

POST /v1.0/myorg/groups/asd123-asd5556-asdasd564/dashboards/asd345-asd789-asd456/GenerateToken HTTP/1.1
Host: api.powerbi.com
Content-Type: application/json; charset=utf-8
Authorization: Bearer ayJ0eXZAiOiJKX1QiLCJhbGciO...

{"accessLevel": "View"}

3. Embeded with JS in client

 

     // Read embed application token from Model
    var accessToken = "<?=$dashboard_token_data['token']?>";

    // Read dashboard Id from Model
    var embedDashboardId = "<?=$dashboard_id?>";

    // Read embed URL from Model
    var embedUrl = 'https://app.powerbi.com/dashboardEmbed';

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;

    // Embed configuration used to describe the what and how to embed.
    // This object is used when calling powerbi.embed.
    // This also includes settings and options such as filters.
    // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
    var config = {
        type: 'dashboard',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedDashboardId
    };

    // Get a reference to the embedded dashboard HTML element
    var dashboardContainer = $('#dashboardContainer')[0];

    // Embed the dashboard and display it within the div container.
    var dashboard = powerbi.embed(dashboardContainer, config);

 

 

Dashboard loads and get updates but following requests failed with 401:

 

Failed to load resource: the server responded with a status of 401 (Unauthorized)wabi-west-europe-redirect.analysis.windows.net/powerbi/metadata/user/activedashboard/947870
Failed to load resource: the server responded with a status of 401 (Unauthorized)wabi-west-europe-redirect.analysis.windows.net/powerbi/metadata/models/718093/?modelOptions=Default&packageId=1278570
Failed to load resource: the server responded with a status of 401 (Unauthorized)wabi-west-europe-redirect.analysis.windows.net/powerbi/metadata/models/718093/?modelOptions=Default&packageId=1278570

 

 

Seems that it's doesn't affect functionality for now. Just wandering what might be the cause.

6 Replies

  • Same issue here. Trying to embed dashboard, seems to render the dashboard but pinned tile is not updated.
    Getting same 400 error in console

    Seems like 'loaded' event is triggered but not 'rendered' or 'error'.

    Has anyone got Tiles to update in a embeded dashboard. Works fine from app.powerbi.com (using push dataset)

  • I am having the same exact problem right now. Has anyone found a solution?

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    calm1kov

    I can confirm the 401 errors when embedding reports or dashboards. However the reports/dashboards can be rendered without problem.

     

    Besides embedding, even when I access Power BI.com and view my reports, I would see 40x and 50x errors in the console as well. I'd guess it is something wrong with the Power BI azure structure, however as long as  those errors don't affect my reports, I just leave them alone.

     

     

    For more clarification, I think you can submit a support ticket.