Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
i-ivanov-09266
New Member

Power BI: 401 error when trying to acquire an access token (ConfidentialClientApplication.acquireTok

Code (basically the same as the sample application in the Azure tutorial for Power BI embedded):

private async getAccessToken() {
        const clientApplication = new msal.ConfidentialClientApplication({
            auth: {
                clientId: config.authClientID,
                authority: `https://login.microsoftonline.com/${config.authTenantID}`,
                clientSecret: config.authClientSecret,
            }
        });
        return await clientApplication.acquireTokenByClientCredential({
            scopes: ["https://analysis.windows.net/powerbi/api/.default"],
        });
    }

I have verified that the following parameters are correct:
- `config.authClientID`
- `config.authTenantID`
- `config.authClientSecret`

 

I also have:
- Granted all possible Power BI Service permissions to my Service Principal (in the Azure App Registration).
- Granted access for my Service Principal in the Power BI admin portal (through a security group).

 

Here is the error I get when running this function:

network_error: Network request failed. Please check network trace to determine root cause. | Fetch client threw: Error: HTTP status code 401 | Attempted to reach: https://login.microsoftonline.com/{my tenant id}/oauth2/v2.0/token

 

What could I be doing wrong?

Thanks in advance

2 REPLIES 2
Anonymous
Not applicable

Hi @i-ivanov-09266 ,

 

It seems like a network error, as the error message says. Can you access the following link successfully? Have you open firewall or proxy?

vmengzhumsft_0-1664766292618.png

You can use "developer tool" to check your error.

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi!

 

Yes, I can access the link in the browser. This is what appears:

iivanov09266_0-1664788327908.png

 

 

The error code I get when trying to acquire a token is 401 - unauthorized, which does not seem to be a network error, but a permission error. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.