Power BI Embed Dashboard: Cross-Origin requests blocked for /powerbi/refresh/subscribe

Viewed 2355

I got a CORS error when Embedding a PowerBI dashboard.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://wabi-west-europe-b-primary-redirect.analysis.windows.net/powerbi/refresh/subscribe. (Reason: CORS request did not succeed).

This is due to POST /powerbi/refresh/subscribe that eventually gets canceled.

POST https://wabi-west-europe-b-primary-redirect.analysis.windows.net/powerbi/refresh/subscribe

Response: 401

Access-Control-Allow-Origin: https://app.powerbi.com
Access-Control-Expose-Headers: X-PowerBI-Error-Info,X-PowerBI-Error-Details
Cache-Control: no-cache, no-store, must-revalidate
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-PowerBI-Error-Info: TokenExpired

Note that these are all coming from MS server.

Any thoughts or why PowerBI had an error TokenExpired?

1 Answers

It appears, from the error message, that you encountered in a situation where your PowerBI Token (AAD or EmbedToken) is expired.

You can set a new token and continue working using: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Update-Embed-Token

All you need to do is listen for this error and once it happens, acquire a new(er) token and update it.

On handling errors: https://powerbi.microsoft.com/en-us/blog/power-bi-developer-community-august-update-2018/#error%20troubleshooting

Of course, if you created the access token, you can set a timeout to refresh it before it expires

Related