# Power BI Embedding in iframe with OAuth

**URL:** <https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936>\
**Category:** Ignition\
**Tags:** webdev, scripting, perspective\
**Created:** [July 30, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936 "2024-07-30T18:57:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M.O](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@M.O](https://forum.inductiveautomation.com/u/M.O)\
**Post date:** [July 30, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936/1 "2024-07-30T18:57:34Z")

</div>

Hi,

I am looking to embed a Power BI report in a Perspective iFrame component and have it automatically authenticate using a service principal object from our Azure AD environment.

I am loosely basing my steps off of this process, for reference.  
[Power BI Embedded Implementation using Service Principal and Python (alphabold.com)](https://www.alphabold.com/power-bi-embedded-implementation-using-service-principal-and-python/)

Through the scripting module and the urllib2 library, I am able to successfully authenticate (OAuth2) and then retrieve the embed URL and embed/access tokens with a series of REST calls to the APIs that Power BI provides. The final REST call to get the embedded report is below. I am using a Bearer token to authenticate:

```python
embedUrl = system.net.httpGet(str(embedConfig['embedUrl']),headerValues= {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + str(embedToken['token'])})

```

Then, I am using Web Dev module to retrieve the html from that call so that the iFrame source can refer to it.

DoGet in Web Dev:

```python
	embedUrl = powerBI.testpowerbi()
	embedUrl = system.util.jsonDecode(embedUrl)
	return {'html': str(embedUrl)}

```

iFrame source property pointed to the WebDev resource:

```python
http://[server]:[port]/main/system/webdev/[project]/powerBI

```

Now when the iFrame loads, it is just waiting for the Bearer authorization tokens and keeps spinning.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/55e1bdd00617215967fb6817251751adbb962b07.png)

My question here is whether anyone has done this before or if it is possible in Ignition. Microsoft provides a Javascript based API for custom applications that specifically attaches the necessary embed data to the HTML element. I am essentially trying to replicate that API in our Ignition environment in order to automatically authenticate the embedded report.  
[Embed a report in Power BI embedded analytics | Microsoft Learn](https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/embed-report)

---

<div class="post-metadata">

**Author:** ![Patrick\_Mannion](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick_mannion/32/72598_2.png) [@Patrick\_Mannion](https://forum.inductiveautomation.com/u/Patrick_Mannion)\
**Post date:** [August 13, 2024, 8:49pm UTC](https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936/2 "2024-08-13T20:49:41Z")

</div>

Any luck here? Been considering doing this myself. I am thinking about a local nodeJS app to handle the auth and rendering and just HTTP calling that in my iFrame

---

<div class="post-metadata">

**Author:** ![M.O](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@M.O](https://forum.inductiveautomation.com/u/M.O)\
**Post date:** [August 13, 2024, 9:29pm UTC](https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936/3 "2024-08-13T21:29:21Z")

</div>

Unfortunately, no. Not without a separate application (such as a nodeJS app like you mentioned) to handle the authentication using Microsoft's APIs. We were trying to avoid doing this using a separate app.

---

<div class="post-metadata">

**Author:** ![Patrick\_Mannion](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/patrick_mannion/32/72598_2.png) [@Patrick\_Mannion](https://forum.inductiveautomation.com/u/Patrick_Mannion)\
**Post date:** [August 19, 2024, 12:49am UTC](https://forum.inductiveautomation.com/t/power-bi-embedding-in-iframe-with-oauth/93936/4 "2024-08-19T00:49:18Z")

</div>

That's what I figured - thank you!
