Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
EraseEgo
Frequent Visitor

Embedding with App owns data using client side Javascript alone

Is it possible to embed Power BI reports in the App owns data scenario with just client side Javascript? That is, with no backend application using Node JS or some other server side technology. 

 

The example that MS provides has the User owns data scenario in React (client only with no server side code). 

 

Is that a limitation imposed by the inability to pass the Azure AD app client secret in a client only Javascript scenario?

3 REPLIES 3
jamesqubit
New Member

Basically you need a backend server to generate a token as-per the app-owns-data flow if your clients will not have their own PowerBI accounts, as the tokens expire so cannot simply be embedded, and embedding the client secret would be insecure in client-side Javascript.  There are a range of samples here:
https://github.com/microsoft/PowerBI-Developer-Samples

Your backend will authenticate with Azure (a few choices available, such as service principal, but this is where a private secret comes into play) and that user will need a couple of permissions in AAD to reach PowerBI, and it will need permissions on the relevant report/data/etc (usually this means putting them in one workspace and grant the permission on there).

There is a good demo of the required values with embedding here https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html, which is handy for grabbing details to test with or to test tokens you have generated.

 A small azure function could handle returning a token for your application without building a whole website for this, such as this: https://www.c-sharpcorner.com/article/create-an-azure-function-app-to-generate-token-power-bi-embedd....

Ultimately if you chose to embed the private secrets then the node samples should be adaptable to client-side only, but I would recommend fetching the certificate or secrets and storing on-device in a secure location rather than including in the JS source.

v-lionel-msft
Community Support
Community Support

Hi @EraseEgo ,

 

Yes, you do not need to configure the server side of your website or application.

Please refer to this.

Embed a Power BI report in React JS to get report instance 

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Lionel,

 

Thank you for your reply. However, in that example, they start with a token. My question is how do you get the token in a Javascript only app. I believe that maybe the reason App Owns Data is not possible in a Javascript only scenario. There is not a way to use the Client Secret in a Single Page App without a Backend server. 

 

Please let me know if it is possible to do App Owns Data (not User owns Data where user has to provide the credentials while accessing the report) without Server side code completely in Javascript.

 

Thanks

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors