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's 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