Fix Power BI REST API 401 Unauthorized for Daemon Application
Question details
The user is encountering an HTTP 401 Unauthorized error when attempting to use the Power BI REST API with a daemon application.

- Product
- Power BI
- Device & OS
- not provided
- Scenario
- Accessing Power BI data programmatically using a daemon app with app-only tokens and the .default scope.
- Observed behavior
- The API returns an HTTP 401 Unauthorized error because the service principal access, tenant settings, or application permissions are not configured correctly.
Ensure you have Power BI Administrator privileges or can contact your tenant administrator, as resolving this requires accessing Microsoft Entra ID (Azure AD) and the Power BI Admin portal.
Enable Service Principal Access in Power BI Tenant Settings
Resolve the 401 error by ensuring the service principal is allowed to use Power BI APIs and has explicit access to the target workspace.
Daemon applications use app-only tokens which identify as service principals. By default, Power BI blocks service principals from utilizing its REST APIs. You must explicitly allow them in the admin portal.
Log into the Power BI service using an account with Power BI Administrator privileges and open the Admin portal from the settings gear icon.
Navigate to 'Tenant settings' and scroll down to locate the 'Developer settings' section.
Toggle 'Allow service principals to use Power BI APIs' to Enabled. You can apply this to the entire organization or specific security groups.
Go to the specific Power BI workspace your app is trying to access, click 'Access', and add the service principal (app name) as a Member or Admin.

Verify Application Permissions and Admin Consent
Check that the registered Azure AD application has the correct API permissions granted and consented by an administrator.
Need a seamless way to handle your local data and reports? Try WPS Office
While Power BI handles complex cloud dashboards, WPS Spreadsheet offers a powerful, lightweight, and free solution for offline data analysis, reporting, and visualization. It perfectly supplements your data workflow without complex API configurations.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded installer and follow the simple on-screen instructions to set up the software.
- 3. Start Analyzing Data: Open WPS Spreadsheet to import your CSV or Excel exports from Power BI and begin your local data analysis seamlessly.

Frequently Asked Questions
Why does my daemon app work with delegated permissions but get 401 with app-only tokens?
App-only tokens require Application-level permissions in Azure AD and explicit Admin consent. Additionally, the service principal must be specifically enabled in the Power BI tenant settings under 'Allow service principals to use Power BI APIs'.
Can I use the Dataset.ReadWrite.All scope for every Power BI API scenario?
No, certain Power BI REST APIs do not support the Dataset.ReadWrite.All scope, particularly those outside specific dataset operations. You must verify the exact scope requirements for your specific endpoint in the official REST API documentation.
What scope should I request when generating the token for my daemon application?
For daemon applications utilizing the client credentials flow to get an app-only token, you should use the https://analysis.windows.net/powerbi/api/.default scope. This scope dynamically uses the permissions explicitly granted to the application in Azure AD.




