Hi,
I'm trying to embed a report using workspace collections while utalizing row level security. I'm using javascript and hence the Power Bi REST API.
I understand that the steps are:
Get access token from azure AD [1] -> get embed token (with access parameters passed in) from power bi -> place embedded content on your website.
I'm using the following REST POST call to get my access token. This works fine.
> POST /common/oauth2/token HTTP/1.1> Host: login.windows.net> Content-Type: application/x-www-form-urlencoded | client_id=<app_client_id>&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username=<powerbi_username>&password=<powerbi_password>&client_secret=<app_client_secret>
Since my report is in a workspace collection, the only things I can see using the command line is collection name, workspace ID, and report ID. In the following REST API call, you can see that it needs a group ID and a report ID. I have the report ID but not sure how to go about getting the group ID. I also understand that the row level security access is defined in the body, so I don't have a problem with the RLS part.
POST https://api.powerbi.com/v1.0/myorg/groups/{group_Id}/reports/{report_id}/GenerateToken { "accessLevel": "View", "identities": [ { "username": "EffectiveIdentity", "roles": [ "Role1", "Role2" ], "datasets": [ "fe0a1aeb-f6a4-4b27-a2d3-b5df3bb28bdc" ] } ] }
Currently I'm generating the embed token using the powerbi CLI tool. I'm using the command:
powerbi create-embed-token -c <collection_name> -k <access_key> -w <workspace_ID> -r <report_ID>
When I do embed, I get the following errors:
I'm embedding using:
<html><body><div id="reportContainer"></div><script src="./node_modules/powerbi-client/dist/powerbi.min.js"></script><script> (function () { var embedToken = '<token from powebi create-embed-token>'; var reportId = '<report id from workspace collections>'; var embedUrl = 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=' + reportId; var config = { type: 'report', accessToken: embedToken, embedUrl: embedUrl, id: reportId, settings: { filterPaneEnabled: false, navContentPaneEnabled: false } }; powerbi.embed(document.getElementById('reportContainer'), config); })();</script></body></html>
Any thoughts?
Thank you.