Search code examples
node.jsaccess-tokenpowerbi-embedded

PowerBI Embed Token using NodeJS unable to Resolve Token Authorization URL


What i am trying to achieve is to embed existing PowerBI report to my Angular Application. To get PowerBI Embed Token, I am using the code as shared in this URL for NODEJS [https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/NodeJS].

When I run via my local machine as API and call via Angular, it throws this error as follow: error: 'ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://login.microsoftonline.com/##TENANTID##/v2.0/.well-known/openid-configuration'. This is the same when I run via AWS EC2 with our internal corporate Proxy.

However if I run EC2 with Elastic IP (without corporates proxy) it works all fine. I have limitation and must run with Corporate Proxy.

My real concern here is we have the same CODE in PYTHON (same GITHUB link) that works in all environment and with corporate proxy and no trouble to get token.

I am seeking help with NODEJS and point out how it differ in behavior with Python code. How i can able to have this code run with internal corporate Proxy since I can't use Direct Elastic IP.

Note: I used the code as-is from GITHUB and added only config details as it require.


Solution

  • For service principal authentication, we need to authenticate using client Secret. MSAL Angular currently doesn't support Confidential Client applications.

    So, we need to use Backend capable of holding secret and to get the Embed token, one workaround I tried is using the Azure Function App as implemented in my GitHub Repo. Once You get the Function URL, you can embed the report in any language by fetching the details from the URL.

    In my repo, embedded the report using powerbi-client-react. You can implement the same and embed the report using powerbi-client-angular.