Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
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?
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:
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.