简体   繁体   English

Firebase身份验证不适用于Chrome

[英]Firebase auth is not working on chrome

I don't know when it happened because as I was developing I had a started session in my browser so I didn't have to login through providers as Google or Facebook again. 我不知道它什么时候发生,因为在我开发的过程中,我在浏览器中启动了一个会话,因此我不必再通过Google或Facebook登录供应商了。 When a new user tried to login in my web app she told me that there was an error. 当新用户尝试在我的网络应用程序中登录时,她告诉我发生了错误。 So I cleaned my browser data and started to have the message A network error (such as timeout, interrupted connection or unreachable host) has occurred. 所以我清理了我的浏览器数据,并开始收到消息A network error (such as timeout, interrupted connection or unreachable host) has occurred. when the browser try to open a popup of Google or Facebook login. 当浏览器尝试打开谷歌或Facebook登录弹出窗口时。 It doesn't happen in Safari or in my Android Chrome. 它不会发生在Safari或我的Android Chrome中。

Here's a code snippet as reference. 这是一个代码片段作为参考。

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

I think you should initialise the app before someone clicks on Login. 我认为你应该在有人点击登录之前初始化应用程序。

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

Whenever someone lands on page maybe the best place to do this. 每当有人登陆页面时,也许是最好的地方。

I went to chrome://settings/content/cookies and clicked Remove all . 我去了chrome:// settings / content / cookies并点击全部删除 That fixed it for me. 这为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM