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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
moizsherwani
Continued Contributor
Continued Contributor

PowerBI Embed Issue

We need to embed a powerBI report into our website dashboard.

To access a powerBI report, the user needs to be authorized and authenticated.

For this we authenticate the user using Microsoft Office 365 Online Services, using the code below:

var settings = {
"async": true,
"crossDomain": true,
"url": "https://login.microsoftonline.com/6c7d5dfa-3948-4782-b5a0-6fd1b2825ae3/oauth2/token",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache",
},
"data": {
"grant_type": "password",
"scope": "openid",
"resource": "https://analysis.windows.net/powerbi/api",
"client_id": "e701f962-2236-434d-8974-19b649b34590",
"username": "w******@exceedgulf.com",
"password": "**********"
}
}

$.ajax(settings).done(function (response) {
console.log(response);
});

Above code snippet works fine if we access using local machine, or a developer tool like Fiddler or Postman. But when we deploy the same code on our website which is hosted on Azure with a custom domain associated with it. We get an error related to

"Failed to load https://login.microsoftonline.com/...../oauth/token: Resposne to preflight request does not pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://exoppdev.azurewebsites.net' is therefore not allowed access.

After investigating from multiple blogs and forums, we almost tried every resolution that can possibly resolve the issue but till not we are not able to load the report from online hosted environment.

Need help regarding above issue.

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.
2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @moizsherwani,

 

As we can see from the error message, it seems not the issues caused by Power BI. Please refer to docs/Web/HTTP/CORS and Headers/Access-Control-Allow-Origin.

I would suggest you mask these ids in your post.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The CORS problem is not on our side, but on the Microsoft end.

 

We are the Calling party, so we cannot set the response headers.

 

We make call to Microsoft online rest api services, and it works locally and not from domain.

 

var settings = {

"async": true,

"crossDomain": true,

"url": "https://login.microsoftonline.com/6c7d5dfa-3948-4782-b5a0-6fd1b2825ae3/oauth2/token",

"method": "POST",

"headers": {

"Content-Type": "application/x-www-form-urlencoded",

"Cache-Control": "no-cache",

},

"data": {

"grant_type": "password",

"scope": "openid",

"resource": "https://analysis.windows.net/powerbi/api",

"client_id": "e701f962-2236-434d-8974-19b649b34590",

"username": "w******@exceedgulf.com",

"password": "**********"

}

}

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.