【发布时间】:2013-08-30 06:40:43
【问题描述】:
我正在使用 AngularJS 设置 oauth2 与 Salesforce 连接。当我尝试使用 $http 进行初始 GET 时,出现 CORS 错误 - 我的客户端不允许访问控制允许来源。但是,在我的控制器功能中使用下面的 hack 是可行的。
鉴于我无法控制服务器,是否有更好的方法在 AngularJs 中执行此操作?我的后端是 Firebase,所以如果我能像 Facebook 一样通过 FIrebase 做到这一点,那就太好了:
$scope.auth = function () {
var authUrl = $scope.AUTHORIZATION_ENDPOINT +
"?response_type=token" +
"&client_id=" + $scope.CLIENT_ID +
"&redirect_uri=" + "https://www.xyz/";
window.location = authUrl ;
【问题讨论】:
-
您可以考虑使用
$location服务为您执行重定向:docs.angularjs.org/guide/dev_guide.services.$location,但除此之外,此方法似乎还不错。 -
感谢您的反馈。也许您可以在相关问题上为我指明正确的总体方向?我在同源的痛苦世界中 - stackoverflow.com/questions/18541976/…
标签: angularjs salesforce firebase firebase-security angularfire