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.
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
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.
User | Count |
---|---|
12 | |
2 | |
2 | |
1 | |
1 |