在Rails中使用Firebase时发生密码错误

时间:2018-10-13 23:19:29

标签: ruby-on-rails firebase-authentication ruby-on-rails-5

我正在Rails应用程序中尝试使用Google登录进行Firebase身份验证。

当用户单击“登录”按钮时,会弹出一个带有Google提示的登录弹出窗口。

但是我一直收到这个错误消息

TypeError: this.ta is not a function[Learn More] firebase.js:1:100034
Ii   https://www.gstatic.com/firebasejs/5.5.3/firebase.js:1:100034
r    https://www.gstatic.com/firebasejs/5.5.3/firebase.js:1:196629
<anonymous>   http://localhost:3000/:39:27

autheticate.erb.html

<h1>Authentication Test</h1>
<button id="sign">Signin</button>
<script src="https://www.gstatic.com/firebasejs/5.5.3/firebase.js"></script>
<script>
  var config = {
    apiKey: "api_key",
    authDomain: "mydomain",
    databaseURL: "database_url",
    projectId: "myproject",
    storageBucket: "bucket",
    messagingSenderId: "message_id"
  };

  firebase.initializeApp(config)

  let elem = document.getElementById("sign");
  elem.addEventListener("click", function(){
    let google_provider = firebase.auth.GoogleAuthProvider()
    firebase.auth().signInWithPopup(google_provider).then(function(result){
      console.log("succesful.... Google account linked")
      console.log(result)
    }).catch(function(err){
      console.log("Failed...... ")
    })
  })

我正在使用

Firebase v 5.5.3

rails v 5.6.1

1 个答案:

答案 0 :(得分:1)

由于以下行而发生错误:

 let google_provider = firebase.auth.GoogleAuthProvider()

new应该使用:

 let google_provider = new firebase.auth.GoogleAuthProvider()