Forum Discussion
REST API - Refresh User Metadata
Ultimately to get around the 403 issues I was having with the Power BI API I had to add the following to my "endpoints" configuration for ADAL.js:
endpoints: {
'https://api.powerbi.com': 'https://analysis.windows.net/powerbi/api',
},
Also since using ADAL.js does not support interactive user prompts for permissions, after I set up the permissions for Power BI in the Azure AD App Registration, I had to click Grant Permissions to grant those permissions to the app for all users.
Also I had to set my IFrame up like below so that when it had fully loaded the URL that the URL returned from the /myorg/groups/:groupId/reports or /myorg/groups/:groupId/dashboards API call, it would set the token. "controller.selectedReport" was the embed URL returned from the API call and "controller.type" was either "Report" or "Dashboard"
<iframe id="report" ng-src="{{controller.selectedReport}}" onLoad="iframeLoaded();" frameborder="0" style="height:{{controller.screenHeight}}px; width:100%;"></iframe>
window.iframeLoaded = function () {
var iframe = document.getElementById("report");
var token = adalService.getCachedToken("https://analysis.windows.net/powerbi/api");
iframe.contentWindow.postMessage(JSON.stringify({ action: "load" + controller.type, accessToken: token }), "*");
};
Glad you got this working!
FYI there is some documentation here describing the requirement for Azure permissions to the app registration for the sample:
https://docs.microsoft.com/en-us/power-bi/developer/register-app
Jon