Forum Discussion
Generate Power BI API Token Without User Interaction for Scheduled Report Exports
- 1 year ago
Hi Himanshu_G,
Can try using a Service Principal (App Owns Data) is a secure, scalable, and reliable way to automate Power BI report exports. It lets your system access Power BI without needing a user to log in, making it perfect for scheduled tasks. This approach ensures that reports are delivered consistently and securely, while also reducing manual work—providing a better experience for your team and your customers.
Please refer to below documentation for same and let me know if this helps.
https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal?tabs=azure-portalThanks,
Prashanth Are
MS Fabric community support
We need to export Power BI reports using the Power BI REST API and send them via email on a scheduled basis in a User Owns Data scenario. The challenge is that obtaining an access token requires user authentication, but we need a way to generate the token automatically without user interaction to support scheduled email delivery.
Requirement
We are looking for a solution to:
- Programmatically authenticate and retrieve an access token for Power BI APIs without manual login.
- Automate report exports and send them via email at scheduled intervals.
- Ensure compliance with User Owns Data authentication requirements while maintaining security best practices.
Has anyone successfully implemented this? What are the best practices to achieve this securely? Any guidance would be greatly appreciated!
Hi Himanshu_G
To programmatically generate a Power BI API access token without user interaction for scheduled report exports in a User Owns Data scenario, the recommended and secure approach is to implement service principal authentication using Azure AD app registrations.
While User Owns Data typically involves delegated permissions and user context, automation without manual login is achievable by shifting to a Service Principal or Service Account model with appropriate permissions assigned. In this setup, you register an application in Azure AD, grant it API permissions to Power BI, and use a client secret or certificate to authenticate via OAuth2.0 to obtain tokens programmatically. This allows your backend service or script to fetch a token and call the Power BI REST API to export reports and send them via email at scheduled intervals using tools like Power Automate, Azure Functions, or custom code.
It’s important to ensure that the service principal has access to the necessary workspaces and datasets, and to store secrets securely (e.g., in Azure Key Vault). While this approach leans toward the App Owns Data model, it is often adapted in User Owns Data workflows when automation is a priority.