I'm trying to embed an existing Power BI Report within our application. From my understanding, the process to do that is as follows...
- Given an embed url, something like...
https://app.powerbi.com/reportEmbed?reportId=xxx&autoAuth=true&ctid=xxx
Obtain groupId (workspaceId) of report ❓❓❓
Generate embed token through the Power BI API
POST https://api.powerbi.com/v1.0/myorg/groups/${groupId}/reports/${reportId}/GenerateToken
Our API then returns the token back to the client and the token is used by the powerbi-client sdk to show the report. I'm purposefully simplifying how to display the report in the UI as it's not applicable for my issue.
My question is... given the embed url of a report https://app.powerbi.com/reportEmbed?reportId=xxx&autoAuth=true&ctid=xxx, how can I obtain the groupId of that report so I can generate an embed token?
Or perhaps there's a better way to go about obtaining the embed token for an embed URL altogether. I'm open to suggestions.
I figured it out so I'll answer my own question in case anyone else has a similar issue.
1. Get a list of reports
myorg/admin/reportsreturns the reports available to the tenant. The response provides the workspace ID for each report.Find the correct report
The accessing service principal or user will need
Tenant.Read.AllorTenant.ReadWrite.All. Additionally, there are some caveats on permissions when accessing this endpoint. Please see the documentation page of this endpoint for additional information.2. Request Embed Token
Now that I have the workspace ID for the given report, I can make a request for an embed token that's valid only for that report.