Forum Discussion
Getting access token for user owns data (UOD) using JavaScript
Hi austinhag,
1. For the purpose of demo, these parameters including embed token are predefined and are updated automatically.
2. How can we get the embed token? Please refer to https://www.youtube.com/watch?v=GPHHdDRSlis and Embed-API-Sample.
3. The pure Javascript approach of getting access token could be azure-activedirectory-library-for-js.
Best Regards,
Dale
Thanks Dale for the reply! I have all the components of the AAD approach in place except for the access token creation. I have my app all setup and registered in AAD as required. I also used the PowerBI-Developer-Samples code to test and grab the dashboard ID and embed URLs and confirmed that those work in my app (I'm able to see the tiles in my app using those IDs and the temporary access token generated by the sample code), etc. However, I was assuming/hoping that the access token generation would be part of a standard javascript library such the powerbi-client Javascript library. It sounds like it is not. I will use the ADAL to generate it. Perhaps this is because the token generation process would ideally be split between the browser and server with browser managing AAD sign-in, receiving the authorization code, passing that to the server which obtains the access token on behalf of the user (thus keeping the client ID and secret hidden)? The browser then receives the access token from the server and uses it to request Power BI tiles, etc. Is that the ideal flow?