Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I am embedding a power BI report using the Javascript API.
The application is a jQuery and Javascript front-end and using a WCF Rest API.
I do the authentication in the Rest API, no integrated domain authentication, and it works as I am getting an access token,
which I then pass back to the front-end.
This has been working just fine, until yesterday when I started getting the below errors on the client (using Chrome).
Nothing changed on my end.
Herewith is my embed code:
_accessToken is the object I got frm mny Rest API with the auth token.
var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=" + _accessToken.reportid + "&groupId=" + _accessToken.groupid;
var models = window['powerbi-client'].models;
var config = {
type: 'report',
accessToken: _accessToken.token,
embedUrl: embedUrl
, settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true,
background: models.BackgroundType.Transparent
}
};
// Grab the reference to the div HTML element that will host the report.
var reportContainer = document.getElementById('dashboard-content');
// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config);
And here is the C# to get the access token
Dictionary<string, object> tokendata = new Dictionary<string, object>();
try {
var credential = new UserPasswordCredential(PowerBIUsr,PowerBIPwd);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
var authenticationResult = await Task.Run(() => authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", PowerBIClientId.ToString(), credential));
if (authenticationResult == null) {
tokendata.Add("error", "{athfailed}");
} else {
tokendata.Add("reportid", this.Settings.PowerBIRepId);
tokendata.Add("groupid", this.Settings.PowerBIGrpId);
tokendata.Add("clientid", this.Settings.PowerBIClientId);
tokendata.Add("token", authenticationResult.AccessToken);
tokendata.Add("tokentype", authenticationResult.AccessTokenType);
tokendata.Add("tokenexpiry", authenticationResult.ExpiresOn);
}
} catch (Exception ex) {
tokendata.Add("error", "{athfailed}");
tokendata.Add("errorO", ex);
}
this.TokenData = tokendata;
Any help will be much appreciated
Kind regards
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |