OAuth的传输不可用
Transport Unavailable for OAuth
我正试图用谷歌登录到我的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);
})
}]);
这可能意味着您正在脱离文件系统
为了运行Auth方法,您必须在真正的服务器上工作。一般来说,从本地服务器而不是文件系统进行开发是一种很好的做法,因为这更接近于生产环境的行为。
尝试http-server
npm模块以快速启动和运行。
我在开发firebase中托管的angular应用程序时遇到了同样的问题。
它在浏览器中运行良好,但当在iOS网络视图应用程序中打开它时,当尝试登录facebook时,它开始获得TRANSPORT_UNAVAILABLE。
首先,我进入了处理弹出和重定向的firebase文档,这让我进入了authWithOAuthRedirect
,但它也不起作用。
在这之后,我发现我使用的是一个关于authWithOAuthRedirect
的已知问题的firebase版本,该问题在2.4.1版本上得到了解决因此,请确保您使用的是2.4.2版本,或者将您的应用程序迁移到firebase3.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);
}
});
};
})
相关文章:
- d3js文本传输-示例代码不起作用
- 使用Yelp API时出现OAuth错误
- 通过AJAX传输变量
- 派生进程的stdout在管道传输时工作异常
- 使用Tabris-js,并尝试使用cordova文件和文件传输插件
- Dropbox oauth认证的IF语句的第二部分是't已触发
- 使用Emscripten Worker API传输数据而不进行复制
- 使用Oauth使用Javascript访问Api
- http://oauth.googlecode.com/svn/code/javascript/oauth.js已关闭,
- 通过html5/websocket通过wifi传输文件
- Instagram oauth flow in angularjs
- Slack Oauth/Authorize API Call
- 通过socket.io从浏览器流式传输视频
- 如何在谷歌开发者控制台上为firefox扩展创建oAuth项目
- 如何使用Google撤销Oauth令牌'的Javascript API
- 节点通过FTP流式传输和处理压缩内容
- OAuth和访问令牌
- 在SoundCloud中,使用JavaScript SDK流式传输曲目是否会增加该曲目的playback_count
- Java脚本访问Location标头's OAuth 2的URL片段
- OAuth的传输不可用