如何从我的应用程序调用Power BI API并了解Microsoft API?
我已通过Azure AD库成功授权用户使用JavaScript . 但是,我无法从控制台中的API获得成功的响应 . 我收到了未经授权的错误,没有访问控制允许在请求的资源上出现源头 .
我习惯使用Javascript和Angular进行API调用,但不使用Microsoft API以及如何授权它们 . 我试过阅读文章,但他们超越了我的脑海 .
The errors are as follows
无法加载资源:服务器响应状态为404(未找到)XMLHttpRequest:无法加载https://api.powerbi.com/v1.0/myorg/dashboards . 对预检请求的响应未通过访问控制检查:请求的资源上不存在Access-Control-Allow-Origin标头 . 因此,不允许访问来源http://renniesb.github.io . 响应的HTTP状态代码为404. nope
Repository with my project code
https://github.com/Renniesb/sample_dashboard/tree/gh-pages
Place in repository that shows my Power B.I API call https://github.com/Renniesb/sample_dashboard/blob/gh-pages/app/services/powerbi.service.js
Expected behavior 在控制台中列出仪表板 .
Test site
https://Renniesb.github.io/sample_dashboard . 要测试我使用我的凭据进行授权 . 我如何让这个论坛的用户测试这种行为 . 如何启用凭据?
List of things I've tried already
-
使用以下网站创建了反向代理:http://shawnsimondeveloper.com/nodeproxyangular/使用JSONP hack尝试解决CORS问题 .
-
在webconfig文件中输入调用的来源 .
-
在本地和GitHub上的网页上测试了网站
1 回答
您不应该同时使用CORS和HTTP代理 . 由于您使用的是ADAL JS库,因此它会自动将您的Power BI令牌附加到传出的HTTP请求中 .
您还需要设置以下内容:
此外,仪表板 endpoints 仍然只能在“beta”版本中使用 . 这导致了404的 .
继续使用CORS的标准AJAX调用: