Forum Discussion

vickyprudhvi's avatar
vickyprudhvi
Helper IV
9 years ago
Solved

Validate Power BI Embed Token

HI

I was able to create Embedded Toekn using powerbi create-embed-token Script method using Command Prompt.

I would like to decode this token and validate it. Is there any way of doing it because When I use this token in HTML script.

I am getting error. It says The Content isn't available.

Pls Help

 

 

Thanks,

Raj

  • Eric_Zhang's avatar
    Eric_Zhang
    9 years ago

    vickyprudhvi wrote:

    Hi Eric_Zhang

    Thank you for your reply. I am able to validate using below site but wen I use username and role in the token it is throwing error.

    Below is the script I am using to generate token. But not working. Any thoughts

    var token2 = '{"ver":"0.2.0","wcn":"' + workspaceCollectionName + '","wid": "' + workspaceId + '","rid":"' + reportId + '","iss":"PowerBISDK","aud":"https://analysis.windows.net/powerbi/api","exp":' + exp + ',"nbf":' + nbf + '","roles": "' + roles + '","username": "' + username + '"}'

     


    vickyprudhvi

    I'm not sure if that way to concat the token is valid or not, could you share me any documentation explaining that way to generate a token. I'm more used to Microsoft.PowerBI.Api in this demo in github,  When role and user name needed, I generate a token this way.

     

    var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id,"username",new string[] { "role1", "role2", "role3" });
  • Eric_Zhang's avatar
    Eric_Zhang
    9 years ago

    vickyprudhvi wrote:

    Hi Eric_Zhang

    As you should have heard regarding new changes with respect to embedding. Now that Azure and PowerBI services are combined. I would like to know how to create embed token with RLS in the new concept. Before we were able to create embed token but today;s world embed token is created in PowerBi Services ( Report ID, Group ID, Aurthentication Code). Is there a way to create embed token in our side. I belive the new embed token is not JWT format.


    vickyprudhvi

    For the new Embedding with non-Power BI users, I got the confirmation that the RLS is on the roadmap and will be available in next quarter. So you may not apply RLS for the new concept at this moment.

     

    No, it is no longer JWT format, the' embed token is encrypted in the new concept.

8 Replies

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    vickyprudhvi wrote:

    HI

    I was able to create Embedded Toekn using powerbi create-embed-token Script method using Command Prompt.

    I would like to decode this token and validate it. Is there any way of doing it because When I use this token in HTML script.

    I am getting error. It says The Content isn't available.

    Pls Help

     

     

    Thanks,

    Raj


    Usually the error "the content isn't available" is due to the token expiration, if  the token was generated correctly. You can decode the token following below steps.

     

    1. Go to https://jwt.io/ , paste your token to the left panel.
    2. You'll find an "exp" field in the decoded JSON, copy that number "149xxxxxx".
    3. Go to epochconverter and paste the number, then you'll get  the expiring date.

    By the way, instead of Power BI - CLI(I guess this tool in your case, as you mentioned create-embed-token), you can generate the token every time when embedding in a programming way. Though it is not recommended, you can even generate a token that never expires by changing the official demo code.

    var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id,Convert.ToDateTime("2099-12-31"));
    • vickyprudhvi's avatar
      vickyprudhvi
      Helper IV

      Hi Eric_Zhang

      Thank you for your reply. I am able to validate using below site but wen I use username and role in the token it is throwing error.

      Below is the script I am using to generate token. But not working. Any thoughts

      var token2 = '{"ver":"0.2.0","wcn":"' + workspaceCollectionName + '","wid": "' + workspaceId + '","rid":"' + reportId + '","iss":"PowerBISDK","aud":"https://analysis.windows.net/powerbi/api","exp":' + exp + ',"nbf":' + nbf + '","roles": "' + roles + '","username": "' + username + '"}'

       

      • Eric_Zhang's avatar
        Eric_Zhang
        Microsoft Employee

        vickyprudhvi wrote:

        Hi Eric_Zhang

        Thank you for your reply. I am able to validate using below site but wen I use username and role in the token it is throwing error.

        Below is the script I am using to generate token. But not working. Any thoughts

        var token2 = '{"ver":"0.2.0","wcn":"' + workspaceCollectionName + '","wid": "' + workspaceId + '","rid":"' + reportId + '","iss":"PowerBISDK","aud":"https://analysis.windows.net/powerbi/api","exp":' + exp + ',"nbf":' + nbf + '","roles": "' + roles + '","username": "' + username + '"}'

         


        vickyprudhvi

        I'm not sure if that way to concat the token is valid or not, could you share me any documentation explaining that way to generate a token. I'm more used to Microsoft.PowerBI.Api in this demo in github,  When role and user name needed, I generate a token this way.

         

        var embedToken = PowerBIToken.CreateReportEmbedToken(this.workspaceCollection, this.workspaceId, report.Id,"username",new string[] { "role1", "role2", "role3" });