Firebase:Facebook登录身份验证/网络请求失败

时间:2018-06-05 10:52:49

标签: javascript angularjs cordova firebase ionic-framework

我在这里阅读了与相同错误相关的所有答案,但没有为我找到任何解决方案。 我也重新安装了cordova-plugin-whitelist - 这对我没有帮助 点击“登录”按钮一秒后,我看到一个空白的弹出窗口,然后是auth/network-request-failed, A network error (such as timeout, interrupted connection or unreachable host) has occurred。我的代码中出错。

这是我的js代码(来自Firebase文档的示例):

var provider = new firebase.auth.FacebookAuthProvider();
provider.setCustomParameters({
    'display': 'popup'
    });

firebase.auth().signInWithPopup(provider).then(function (result) {
    // This gives you a Facebook Access Token. You can use it to access the Facebook API.
    var token = result.credential.accessToken;
    // The signed-in user info.
    var user = result.user;
    deferred.resolve()
    // ...
}
).catch(function (error) {
    // Handle Errors here.
    var errorCode = error.code;
    var errorMessage = error.message;
    // The email of the user's account used.
    var email = error.email;
    // The firebase.auth.AuthCredential type that was used.
    var credential = error.credential;
    // ...
    // deferred.reject(err)
});

这是我的注册视图代码:

<ion-view hide-nav-bar="true">
    <ion-content padding="true" class="background">

        <div class="holder">
            <div class="header">
                <h1>App name</h1>
            </div>
        </div>
    </ion-content>


    <div class="bottom padding">
        <button class="button button-block button-green" ng-click="vm.loginFacebook()">
            LOGIN WITH FACEBOOK
        </button>
        <div class="terms">
            By signing in you agree to our
            <br>
            <a href="#" ng-click="vm.openUrl(1)">Terms of Services</a> and
            <a href="#" ng-click="vm.openUrl(2)">Privacy Policy</a>
        </div>
    </div>

</ion-view>

有人有任何想法如何解决这个问题吗?

更新

此问题只能在Google Chrome和Edge中重现。在Firefox中正常工作

更新2

在Firefox中不正确,但奇怪的是发生了,在Firefox中我看到一个谷歌认证窗口两秒钟,然后它关闭自己,我有另一个错误:

auth/network-request-failed. The popup has been closed by the user before finalizing the operation.

1 个答案:

答案 0 :(得分:0)

我无意中找到了答案here。这是一个简单的拼写错误,我写道.firebaseio.com但它应该是authDomain字段中的.firebaseapp.com。