2017-04-10 236 views
1

我不知道它何时发生,因为在开发过程中,我在浏览器中启动了会话,所以我不必再次通过Google或Facebook等提供商登录。当一位新用户试图在我的网络应用程序中登录时,她告诉我发生了错误。因此,我清理了我的浏览器数据,并在浏览器尝试打开Goog​​le或Facebook登录弹出窗口时开始输入消息A network error (such as timeout, interrupted connection or unreachable host) has occurred.。它不会在Safari或我的Android Chrome中发生。Firebase身份验证不适用于Chrome浏览器

下面是一个代码片段作为参考。

<!-- 
@license 
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. 
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 
Code distributed by Google as part of the polymer project is also 
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 
--> 

<link rel="import" href="../bower_components/polymer/polymer.html"> 
<link rel="import" href="../bower_components/paper-button/paper-button.html"> 
<link rel="import" href="../bower_components/polymerfire/polymerfire.html"> 
<link rel="import" href="shared-styles.html"> 

<dom-module id="my-view1"> 
    <template> 
    <style include="shared-styles"> 
     :host { 
     display: block; 

     padding: 10px; 
     } 
    </style> 

    <div class="card"> 
     <div class="circle">1</div> 
     <paper-button on-tap="login">Login</paper-button > 
     <h1>View One</h1> 
     <p>Ut labores minimum atomorum pro. Laudem tibique ut has.</p> 
     <p>Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.Lorem ipsum dolor sit amet, per in n# 
    </div> 
    </template> 

    <script> 
    Polymer({ 
     is: 'my-view1', 

     login: function(){//{{{ 
     firebase.initializeApp({ 
      apiKey: apiKey, 
      authDomain: authDomain, 
      databaseURL: databaseURL 
     }); 

     var provider = new firebase.auth.FacebookAuthProvider(); 
     firebase.auth().signInWithPopup(provider).then(function(result){ 
      console.log(result); 
     }).catch(function(error){ 
      console.error(error); 
     }); 
     },//}}} 
    }); 
    </script> 
</dom-module> 

回答

0

我想你应该在有人点击登录前初始化应用程序。

firebase.initializeApp({ 
    apiKey: apiKey, 
    authDomain: authDomain, 
    databaseURL: databaseURL 
}); 

每当有人登陆页面可能是最好的地方做到这一点。

+0

不是。我已经测试过了。 –

相关问题