Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Trying to do something really really simple - but it seems like you have to scale a 100ft wall every step of the way.
Background:
1) I'd like to use this https://github.com/Microsoft/PowerBI-JavaScript API wrapper to push data / embed PowerBI reports in an "App Owns Data" scenario, authenticating server-side.
2) Following this tutorial, but can't get past the first step
https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data
Problem:
1) Before I can even authenticate, need to register an app. Ok. Tried to follow this https://docs.microsoft.com/en-us/power-bi/developer/register-app.
But, amazingly, the dev.powerbi.com/apps page is broken.
So now, tried to register via the azure portal. I got the ClientID by doing this, but where do I get the ClientSecret, to call the API server side?
2) Let's assume I have the ClientID and ClientSecret. Trying to follow this tutorial now: https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token
But this only has examples using C# auth libraries. And while https://msdn.microsoft.com/library/mt784614.aspx might work for getting Embed Tokens for individual reports etc, I don't think it works for Pushing Data to Datasets.
So I tried to use this:
https://github.com/AzureAD/azure-activedirectory-library-for-js
The closest code sample I can find is
adalAuthenticationServiceProvider.init( { // Config to specify endpoints and similar for your app tenant: "52d4b072-9470-49fb-8721-bc3a1c9912a1", // Optional by default, it sends common clientId: "e9a5a8b6-8af7-4719-9821-0deef255f68e", // Required //localLoginUrl: "/login", // optional //redirectUri : "your site", optional endpoints: endpoints // If you need to send CORS api requests. }
)
but I don't think even this works because there is no ClientSecret being used.
How do I authenticate to AAD from server-side javascript??
3>Let's assume I now have an Access Token , that I can theoretically use with https://github.com/Microsoft/PowerBI-JavaScript
How do I construct an authenticated API request using that library? Documentation here https://powerbi.docs.apiary.io/#introduction/authenticate-with-power-bi says to use an Authorization header entry, but that's for a vanilla REST request...what's the syntax for the API wrapper?
I'm not sure if this process was made intentionally convoluted + lacking in any examples, but I can't imagine how anyone new to this actually uses it. If anyone has any code samples, esp for the authentication piece, I would be very grateful.
Any help is appreciated. Thanks!
Solved! Go to Solution.
As far as I know, the Power BI JavaScript wrapper is only for embedding purpose. It is not for pushing data at all. As to the "App Owns Data" scenario, it usually requires a Native app, so no client_secret is involved. For your interest, you can referece Creating the application Client ID and Client Secret from Microsoft Azure new portal
To get an accesstoken for pushing data, it is the ADAL lib, the github lib you've already known. You can reference sample in @Anonymous last reply in this thread.
By the way, why all in Javascript? For "App Owns Data", it actually uses a master account. While using ADAL, you'll have to do the authentication through a pop up log-on window. I'm not an expert on ADAL however I doubt ADAL would support to do the authentication by passing username&&password instead of the pop-up. Even it supports, I don't think it is a good idea to hard coded the username&&password in your Javascript or Web page, it is definitely risky.
As far as I know, the Power BI JavaScript wrapper is only for embedding purpose. It is not for pushing data at all. As to the "App Owns Data" scenario, it usually requires a Native app, so no client_secret is involved. For your interest, you can referece Creating the application Client ID and Client Secret from Microsoft Azure new portal
To get an accesstoken for pushing data, it is the ADAL lib, the github lib you've already known. You can reference sample in @Anonymous last reply in this thread.
By the way, why all in Javascript? For "App Owns Data", it actually uses a master account. While using ADAL, you'll have to do the authentication through a pop up log-on window. I'm not an expert on ADAL however I doubt ADAL would support to do the authentication by passing username&&password instead of the pop-up. Even it supports, I don't think it is a good idea to hard coded the username&&password in your Javascript or Web page, it is definitely risky.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
39 | |
4 | |
3 | |
3 | |
2 |