代码之家  ›  专栏  ›  技术社区  ›  Joseph D.

power-bi-embed仪表板:阻止/powerbi/refresh/subscribe的跨源请求

  •  3
  • Joseph D.  · 技术社区  · 6 年前

    我在嵌入powerbi仪表板时遇到cors错误。

    已阻止跨源请求:同一源策略不允许读取 位于的远程资源 https://wabi-west-europe-b-primary-redirect.analysis.windows.net/powerbi/refresh/subscribe . (原因:CORS请求未成功)。

    这是因为 POST /powerbi/refresh/subscribe 最终被取消了。

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

    回复: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
    

    注意,这些都来自ms-server。

    有什么想法或者为什么powerbi的错误标记过期了?

    1 回复  |  直到 6 年前
        1
  •  0
  •   RBreuer    6 年前

    从错误消息中可以看出,您在powerbi令牌(aad或embedtoken)过期的情况下遇到了问题。

    您可以设置新令牌并继续使用: https://github.com/Microsoft/PowerBI-JavaScript/wiki/Update-Embed-Token

    您需要做的就是监听这个错误,一旦发生,获取一个新的(er)令牌并更新它。

    处理错误时: https://powerbi.microsoft.com/en-us/blog/power-bi-developer-community-august-update-2018/#error%20troubleshooting

    当然,如果创建了访问令牌,则可以设置超时以在其过期之前刷新它