Forum Discussion
Embeded report in iframe using the API with embedded token
Hi Community,
I'm working on embedding a PowerBI report in an iframe, doing the API calls myself.
We are using oauth2:
8 Replies
- AnonymousNot applicable
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.
- NephilimNew 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
- AnonymousNot applicable
Hi Nephilim ,
Is your problem solved, if so, mark the correct answer as a marker, if not, provide more detailed information and we can help you better!
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.
- NephilimNew Member
Hi Liu Yang,
I still haven't gotten it to work, but I have a few aditional question though. Using your scrUrl for the iframe, you mention "your bearer token generated". I put the response from the GenerateToken endpoint below to illustrate. It's the long string in the token-key that I have to put in the config param of the url right?
Second question, what is the difference between the url you provided and the one I get back from the reports endpoint (with a much shorter config paran in the url) eg:
"embedUrl": "https://app.powerbi.com/reportEmbed?reportId=8655xxx-xxxx-xxxx-xxxx-xxxx89f1f344&groupId=xxxxe9e1-xxxx-xxxx-xxxx-xxxx84c645e0&w=2&config=eyJjbHVz ... ldHJpY3NWTmV4dCI6dxxxxxx",GenerateToken endpoint response:
{"@odata.context": "http://wabi-us-east2-redirect.analysis.windows.net/v1.0/myorg/groups/0386xxxx-xxxx-xxxx-xxxx-xxxx84c645e0/$metadata#Microsoft.PowerBI.ServiceContracts.Api.V1.GenerateTokenResponse","token": "H4sIAAAAAAAEAC2Ux66ZgQmga7we ... pmQxLCJhbGxvd0FbnRlcm5ldCI6dHJ1ZX0=","tokenId": "fb74xxxx-xxxx-xxxx-xxxx-xxxxf4d53b49","expiration": "2024-04-17T09:49:01Z"}
- AnonymousNot applicable
Nephilim were you able to find out the reason?
- Hari_AdinovusNew Member
Nephilim Found any solution? for "The sandbox is too restrictive and preventing correct functioning" error
- vdmcFrequent Visitor
Hi, Hari_Adinovus.
You may wanna check this Forum: Solved: Re: When clicking on Sign-in on embedded report no... - Microsoft Fabric Community.
It's not exactly the same link used to iframe presented here, but it's a very similar problem that also had the same message "The sandbox is too restrictive and preventing correct functioning"