4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

firebaseのauth認証が通らない(not authorized to run this operation)

Posted at

事象

ログイン認証を行うために以下のコードを埋め込んだが、userがどうしてもNullになってしまう。

app.js
  created: function() {
    firebase.auth().onAuthStateChanged(user => {
      console.log(user);
      if (user) {
        this.isLogin = true;
        this.userData = user;
      } else {
        this.isLogin = false;
        this.userData = null;
      }
    });
  },

safariのコンソールを見てみたら、以下エラーが出ていた。

Error: This domain (****.firebaseapp.com) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.

原因

index.html > config が、別のプロジェクトのものであった。
firebaseのプロジェクトの何度か作り直していたため、前のプロジェクトのままだったよう。

index.html
<script>
  // Initialize Firebase
  var config = {
    apiKey: "****",
    authDomain: "****.firebaseapp.com",
    databaseURL: "https://****.firebaseio.com",
    projectId: "****",
    storageBucket: "****.appspot.com",
    messagingSenderId: "****"
  };
  firebase.initializeApp(config);
</script>
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?