Forum Discussion
Embeded report in iframe using the API with embedded token
Hi Nephilim ,
Based on my query and research, it's possible to embed a Power BI report using the generated token instead of relying on user login. Here's how you can achieve that:
- Obtain the access token using OAuth2 authentication. You've already outlined this step, where you retrieve the access token from the https://login.microsoftonline.com/{TenantId}/oauth2/token endpoint.
- Use the access token to call the Power BI REST API to generate an embed token. You've also covered this step, where you call the GenerateToken endpoint.
- Construct the URL for embedding the Power BI report in the iframe. You need to include the report ID and the embed token in the URL
You may try the URL like this
<iframe title="Client Portal Report" width="1140" height="541.25" src=https://app.powerbi.com/reportEmbed?reportId={ReportId}&groupId={GroupId}&config=your bearer token generated&$filter=XXXXX frameborder="0" allowFullScreen="true"></iframe>
Replace {ReportId} and {GroupId} with your report and group IDs, respectively. Also, make sure to replace XXXXX in the $filter parameter with the appropriate filter condition if needed.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Nephilim2 years agoNew Member
Hi Liu Yang,
Thank you for the quick response.
Unfortunately I dont know if it works, because I get as a response: "The sandbox is too restrictive and preventing correct functioning." It blocked some cookies to "playground.powerbi.com".
So I asked our PBI and System collegues to look into it first...
Kind regardsMarc