# Power BI Integration in Android Application with RLS and Client-Managed Credentials
## Table of Contents
1. **Introduction**
1.1 [Purpose](#11-Purpose)
1.2 [Scope](#12-Scope)
1.3 [Audience](#13-Audience)
2. **Prerequisites**
2.1 [Azure Active Directory Registration](#21-Azure-Active-Directory-Registration)
2.2 [Power BI Application Registration](#22-Power-BI-Application-Registration)
3. **Role Level Security Implementation**
3.1 [Define Roles in Power BI](#31-Define-Roles-in-Power-BI)
3.2 [Assign Roles to Users](#32-Assign-Roles-to-Users)
3.3 [RLS Data Synchronization](#33-RLS-Data-Synchronization)
3.4 [Implement RLS in Android App](#34-Implement-RLS-in-Android-App)
4. **Client-Managed Credentials**
4.1 [Portal Integration](#41-Portal-Integration)
4.2 [Secure Storage](#42-Secure-Storage)
4.3 [Dynamic Access](#43-Dynamic-Access)
5. **Embedding Power BI Report in Android App**
5.1 [Power BI JavaScript API](#51-Power-BI-JavaScript-API)
5.2 [Report Embedding Implementation](#52-Report-Embedding-Implementation)
5.3 [Token Acquisition](#53-Token-Acquisition)
5.4 [Data Security](#54-Data-Security)
6. **Conclusion**
7. **Technical Resources**
## 1. Introduction
### 1.1 Purpose
This document provides technical guidance for integrating Power BI into your Android application. The integration enables seamless visualization and interaction with Power BI reports within the app.
### 1.2 Scope
The scope of this document includes the setup of authentication with Azure Active Directory, integration of the Power BI SDK, and embedding Power BI reports in an Android application.
### 1.3 Audience
This document is intended for developers and technical stakeholders involved in the implementation and maintenance of the Android application with embedded Power BI capabilities.
## 2. Prerequisites
### 2.1 Azure Active Directory Registration
Before proceeding, ensure that you have registered your application in Azure Active Directory. Follow the steps outlined in [Azure portal](https://portal.azure.com/) to create the necessary credentials.
- Workspace: Identify relevant Power BI reports.
- Application (client) ID
- Directory (tenant) ID
- Client secret
### 2.2 Power BI Application Registration
Register your application in Power BI to obtain the Application ID required for integration. Visit [Power BI App Registration](https://dev.powerbi.com/apps) and follow the instructions.
- Application ID
## 3. Role Level Security Implementation
### 3.1 Define Roles in Power BI
Define roles in your Power BI service to categorize users based on their roles or access levels. For example, create roles like 'Manager,' 'Employee,' or any other role that aligns with your application's requirements.
### 3.2 Assign Roles to Users
Assign users to specific roles within the Power BI service. This can be done through the Power BI portal or programmatically using the Power BI REST API. Ensure that each user is associated with the appropriate role(s) based on their access requirements.
### 3.3 RLS Data Synchronization
Consider mechanisms to keep RLS rules and user assignments synchronized with Power BI (APIs or manual updates).
### 3.4 Implement RLS in Android App
Integrate Role Level Security into your Android application using the Power BI JavaScript API. Modify the report embedding code to consider the user's role during the embedding process.
## 4. Client-Managed Credentials
### 4.1 Portal Integration
Develop a secure client portal for ENTRA credentials (workspace ID, app registration details).
### 4.2 Secure Storage
Store retrieved credentials securely in your database with encryption and access control.
### 4.3 Dynamic Access
Retrieve required credentials for each report embed based on report and user context.
## 5. Embedding Power BI Report in Android App
### 5.1 Power BI JavaScript API
Utilize the Power BI JavaScript API for embedding reports into the Android app. Refer to the official [Power BI JavaScript API documentation](https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/index) for details.
### 5.2 Report Embedding Implementation
Implement the report embedding functionality in your Android application using the Power BI SDK. Sample code snippets and examples can be found in the official documentation.
### 5.3 Token Acquisition
Fetch appropriate embed token based on selected report and user context using retrieved ENTRA credentials.
### 5.4 Data Security
Ensure secure communication between app, client portal, and Power BI service (HTTPS, tokens).
## 6. Conclusion
This Power BI Embedding Requirement Documentation outlines the technical, security, user experience, testing, documentation, deployment, and maintenance requirements for embedding Power BI content into an application. Adherence to these requirements will ensure a secure, scalable, and user-friendly integration of Power BI reports and dashboards.
## Technical Resources
* Power BI Embedded: [https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/powerbi-client-angular](https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/powerbi-client-angular)
* Power BI Embedded Security: [https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/powerbi-client-angular](https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/powerbi-client-angular)
* Power BI Embedded Android SDK: [https://github.com/topics/powerbi-embedded](https://github.com/topics/powerbi-embedded)
* Microsoft ENTRA: [https://learn.microsoft.com/en-us/entra/](https://learn.microsoft.com/en-us/entra/)
[Document Version: 1.1.1 | Date: 2024-01-29]