我正尝试在我的AngularJS Web应用程序中使用FireBase后端来设置基于重定向的OAuth流的AngularFire登录。 我使用的是AngularJS 1.3.14,Firebase 2.2.3和AngularFire 1.0.0。
我试图建立一个基本的例子,以获得最简单的方法身份验证完成后,以下AngularFire库文档:https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-users-and-authentication
我完成了谷歌应用验证设置,如下所述:https://www.firebase.com/docs/web/guide/login/google.html
在我控制器我做:
var ref = new Firebase("https://xxxxxxx.firebaseio.com");
$scope.authObj = $firebaseAuth(ref);
然后下面的例程绑定到我的界面中的“登录”按钮。
$scope.authObj.$authWithOAuthRedirect("google");
虽然我点击我的“登录”按钮后,我重定向到谷歌,在那里我可以授权我的应用程序,我可以用我的帐号登录。然后我重定向到我的应用程序,但我看到这个错误在JavaScript浏览器(Chrome)控制台:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.14/$rootScope/infdig?p0=10&p1=%5B%5D
at REGEX_STRING_REGEXP (angular.js:63)
at Scope.$get.Scope.$digest (angular.js:14281)
at Scope.$get.Scope.$apply (angular.js:14506)
at bootstrapApply (angular.js:1448)
at Object.invoke (angular.js:4185)
at doBootstrap (angular.js:1446)
at bootstrap (angular.js:1466)
at angularInit (angular.js:1360)
at angular.js:26176
at HTMLDocument.trigger (angular.js:2744)
我想不通为什么出现这种情况,怎么解决。它看起来像在AngularJS引导时发生某种循环。
如果我改变我的$scope.authObj.$authWithOAuthRedirect("google");
与$authWithOAuthPopup
电话线(见下面的确切的代码),一切工作正常:
$scope.authObj.$authWithOAuthPopup("google")
.then(function(authData) {
$log.info("Logged in as:", authData.uid);
}).catch(function(error) {
$log.info("Authentication failed:", error);
});
有了这个代码绑定到我的“登录”按钮,弹出窗口,让我用Google登录,然后我可以在控制台中阅读预期的认证信息:Logged in as: google:[undisclosed-21-digit-number]
。
任何帮助更好地理解AngularFire auth库将不胜感激。 预先感谢您。
如果我在Chrome for iOS上尝试snipplet表单Firebase文档https://www.firebase.com/docs/web/guide/user-auth.html#section-popups(我不支持弹出窗口)无限循环,如下所述:http://stackoverflow.com/questions/27927200/firebase-google-oauth-infinite-redirects。但在我的情况下,我没有无限的重定向,因为我将auth绑定到视图按钮。目前我正在处理一个AngularJS摘要循环。 – Mettiu