Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Power BI Embedded - Access Token

So I have some graphs in Power BI which I want to share with my clients.

I'm making a custom page here on my server and trying to embed those graphs using Power BI Embedded setup.

I'm following this link https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token

However, how do I get an access token via javascript API?

like image 263
asn559 Avatar asked Nov 17 '17 14:11

asn559


2 Answers

Generate EmbedToken is basically a REST API call. you can use NodeJs or AJAX to issue this request and get your EmbedToken.

For AAD auth, I can maybe refer you to ADAL.js: https://github.com/AzureAD/azure-activedirectory-library-for-js

which can help with auth against AAD

like image 113
RBreuer Avatar answered Oct 03 '22 05:10

RBreuer


I don't think that's possible in Javascript at the moment. I tried to create access tokens in Javascript not a long time ago but failed to find a way to do that.

I ended up doing a bit of server side code (something like this https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-get-token) and printed the access code to a hidden div. Then I grabbed the token with Javascript and continued with Javascript from there (created the embed token and embedded the report itself).

It might be possible to do a sort of Javascript solution with a proxy, but that's out of my expertise (the proxy has the server side code).

The only pure Javascript solution I'm aware of is the Publish to web -solution (https://docs.microsoft.com/en-us/power-bi/service-publish-to-web), but it's got some limitations and security issues.

like image 45
Gigga Avatar answered Oct 03 '22 06:10

Gigga