Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18035

Dashboard embed. Requests with 401

$
0
0

 

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&username=user@domain.onmicrosoft.com&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.


Viewing all articles
Browse latest Browse all 18035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>