To embed Power BI reports in an Angular application while using Azure AD authentication, here's how you do it:
Register the App in Azure AD: Register the app in Azure AD, configure the permissions (Power BI API), and acquire the Client ID and Tenant ID for your app.
Install MSAL and Power BI SDK: Use MSAL for Azure AD authentication (@azure/meal-angular) and add the Power BI Java SDK (power bi-client) to make the embed work.
Authenticate Users: You can authenticate your users by using MSAL and acquire an access token by using acquireTokenSilent () or acquireTokenPopup ().
Report Embedding: Call the Power BI SDK in order to use the access token, report ID, and embed URL to the Power BI embed configuration and embed it with the report.
Refreshing the Token: You can refresh tokens manually when they expire; otherwise, you can use the automatic refresh option from MSAL.
Testing Token: Call the API at /reports of the Power BI REST API to test the token.
Safety Tip: Consider generating the token on the server side for additional security and consume short-lifetime token