How to add Power BI reports in Android native app in 2019

前端 未结 1 2014
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 23:15

I am developing an Android application in which I should show Power BI reports and tiles with drill down.

I Googled but still I am not able to find a proper document

相关标签:
1条回答
  • 2020-12-07 00:18

    Here is a working example for you. It shows how to embed Power BI elements in a native desktop application. For android it's basically the same - it loads in a web browser in your app.

    First you need to know that there are two modes for embedding Power BI - user owns data and app owns data. With the first mode, when embedding, the user will authenticate itself using it's own Power BI Pro account, i.e. each of your users needs Power BI Pro license. With the later one, you need only one "master account", which will be used for authentication. The differences in the implementation aren't tremendous, so I will describe app owns data.

    You need to do the following:

    • Register an application - go to dev.powerbi.com/apps and register a native application. Select which permissions to grant it (if you aren't sure, for your first tests simply grant them all). Copy the guid - this is the app ID, a.k.a. client ID.

    • Next step is to authenticate from your application and get an access token. Use Azure Active Directory Authentication Library (ADAL) for that - call some of the acquireToken methods of AuthenticationContext class. Here are the official examples for Android.

    • Use this access token to call the Power BI REST API and get the embedUrl of the element you want to embed, e.g. report.

    • Use Power BI JavaScript client to actually embed this element. You need to initialize one embed configuration class and pass information about element type (report, dashboard, tile), where to find it (embedUrl), authentication (access token), some other configuration options (show or hide filters pane, navigation, etc.), filters to be applied and so on. In case you will use the access token acquired above, set tokenType to be AAD. This token has many privileges, so for security reasons you may want to use Embed token instead. In this case use the access token to call the REST API again (e.g. Reports GenerateTokenInGroup).

    • Call powerbi.embed method of the JavaScript client pass the embedded configuration to visualize this Power BI element in your app.

    0 讨论(0)
提交回复
热议问题