传输对 OAuth 不可用

Transport Unavailable for OAuth

我正在尝试使用 google 登录到我的 firebase 项目,但我在使用 firebase 的弹出和重定向功能时遇到传输不可用错误。是我在本地工作还是我这里做错了什么?

var app = angular.module('WOM', ["firebase"]);
app.controller('SampleCtrl', ['$scope', '$firebaseObject', '$firebaseAuth', function($scope, $firebaseObject, $firebaseAuth){
var ref = new Firebase('https://who-owes-me.firebaseio.com/'); //Where data is stored
var auth = $firebaseAuth(ref);

$scope.login = function() {
    $scope.authData = null;
    $scope.error = null;

    auth.$authWithOAuthPopup("google").then(function(authData){
        $scope.authData = authData;
    }).catch(function(error){
        $scope.error = error;
    });
}

$scope.data = $firebaseObject(ref); //assign data to scope

$scope.data.$loaded()
    .then(function(){
        console.log($scope.data);
    })
    .catch(function(err){
        console.error(err);
    })
}]);

这可能意味着您正在使用文件系统。

为了 运行 身份验证方法,您必须在 bona-fide 服务器上工作。一般来说,从本地服务器而不是文件系统进行开发是一种很好的做法,因为这更接近生产环境的行为方式。

Try the http-server npm module to get up and running quickly.

我在开发 angular 托管在 firebase 中的应用程序时遇到了同样的问题。

它在浏览器中 运行 很好,但是在 iOS webview 应用程序中打开它时,它在尝试使用 facebook 登录时开始变得 TRANSPORT_UNAVAILABLE。

首先,我进入了 Dealing with Popups and Redirects 的 firebase 文档,这让我进入了 authWithOAuthRedirect,但它也没有用。

在此之后,我发现我使用的是关于 authWithOAuthRedirectfirebase version with a known issue,该问题已在 2.4.1 版中解决。 因此请确保您使用的是 2.4.2 版或将您的应用迁移到 firebase 3.0

我仍然 运行 陷入另一个问题,在对此进行更多研究后,我开始将 onAuth 与我的身份验证一起使用。每次您的用户成功通过身份验证时都会调用 onAuth。它让一切变得更容易。

所以我的登录控制器现在看起来如下:

.controller('LoginCtrl', ['$scope', 'Auth', 'fbutil', 'FBURL', function($scope, Auth, fbutil, FBURL) {

    var ref = new Firebase(FBURL);
    ref.onAuth( function(authData){
      if (authData){
        //User authenticated. Do your logic.
      }
    });

    $scope.fbLogin = function() {
      ref.authWithOAuthPopup("facebook", function(error, authData) {
          if (error){
            if (error.code === "TRANSPORT_UNAVAILABLE") {
              Auth.$authWithOAuthRedirect("facebook", function(error) {
                console.log(error);
              });
            }
            $scope.err = errMessage(error);
          }
      });
    };
})