Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next 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

Reply
DirkCoetzee
New Member

Power BI Embed error

 

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.

pbiCapture.PNG

 

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

0 REPLIES 0

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.