【问题标题】:Firebase auth is not working on chromeFirebase 身份验证不适用于 chrome
【发布时间】:2017-04-10 12:42:45
【问题描述】:

我不知道它是什么时候发生的,因为在我开发过程中,我的浏览器中有一个已启动的会话,因此我不必再次通过 Google 或 Facebook 的提供商登录。当一个新用户尝试登录我的网络应用程序时,她告诉我有一个错误。所以我清理了我的浏览器数据并在浏览器尝试打开谷歌或 Facebook 登录弹出窗口时开始收到消息A network error (such as timeout, interrupted connection or unreachable host) has occurred.。它不会发生在 Safari 或我的 Android Chrome 中。

这里有一个代码 sn-p 作为参考。

<!--
@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>

【问题讨论】:

    标签: javascript authentication firebase


    【解决方案1】:

    我认为您应该在有人点击登录之前初始化应用程序。

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

    每当有人登陆页面时,可能是执行此操作的最佳位置。

    【讨论】:

    • 不……不是吗。我已经测试过了。
    【解决方案2】:

    我去了chrome://settings/content/cookies并点击了全部删除。这为我解决了问题。

    【讨论】:

      猜你喜欢
      • 2014-08-16
      • 2020-04-30
      • 2022-01-05
      • 1970-01-01
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      相关资源
      最近更新 更多