Forum Discussion

kiran_subhedar's avatar
kiran_subhedar
Regular Visitor
8 years ago
Solved

QnA Embedding

Hello,

I am following the online QnA example at https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html to embed QnA into a asp.net mvc intranet portal. I am using exactly the same code although modifying the values for embed token, embed url, and dataset id. But all i get in the embededded frame is as below. There aren't any errors in the browser console either. I am getting the access token by following the article at https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token. The intranet portal is internal to Microsoft. Any ideas why this is not working?

 

 

 

  • I finally got it working by specifying tokenType as models.TokenType.Aad instead of models.TokenType.Embed. 

    var config = {
    type: 'qna',
    tokenType: models.TokenType.Aad,
    accessToken: txtAccessToken,
    embedUrl: txtEmbedUrl,
    datasetIds: [txtDatasetId],
    viewMode: models.QnaMode.Interactive,
    question: txtQuestion
    };

4 Replies

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    kiran_subhedar wrote:

    Hello,

    I am following the online QnA example at https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html to embed QnA into a asp.net mvc intranet portal. I am using exactly the same code although modifying the values for embed token, embed url, and dataset id. But all i get in the embededded frame is as below. There aren't any errors in the browser console either. I am getting the access token by following the article at https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token. The intranet portal is internal to Microsoft. Any ideas why this is not working?

     

     

     


    kiran_subhedar

    In embedding scenarios, embedded token starting with H4sIxxx.. is required, instead of an access token. You can get the embedded token with the access token by calling GenerateToken, see Generate token for Q&A

    • kiran_subhedar's avatar
      kiran_subhedar
      Regular Visitor

      I finally got it working by specifying tokenType as models.TokenType.Aad instead of models.TokenType.Embed. 

      var config = {
      type: 'qna',
      tokenType: models.TokenType.Aad,
      accessToken: txtAccessToken,
      embedUrl: txtEmbedUrl,
      datasetIds: [txtDatasetId],
      viewMode: models.QnaMode.Interactive,
      question: txtQuestion
      };

      • Eric_Zhang's avatar
        Eric_Zhang
        Microsoft Employee

        kiran_subhedar wrote:

        I finally got it working by specifying tokenType as models.TokenType.Aad instead of models.TokenType.Embed. 

        var config = {
        type: 'qna',
        tokenType: models.TokenType.Aad,
        accessToken: txtAccessToken,
        embedUrl: txtEmbedUrl,
        datasetIds: [txtDatasetId],
        viewMode: models.QnaMode.Interactive,
        question: txtQuestion
        };


        kiran_subhedar

        I'd suggest using "tokenType: models.TokenType.Embed", the main concern is that the models.TokenType.Aad would have more security risk. The access token would be plaintext in your web page, with the access token anyone can access all reports, dashboards, datasets etc via REST API, while using embedded token which is specific for the embedded objects has narrowed-down access permissions. Meanwhile For feature Row Level Security in Embedding for your customers scenario, you'll have to use embed token.