LoginSignup
0
0

More than 3 years have passed since last update.

FirebaseのGoogleログインではまった

Posted at

はじめに

こんなことをやろうとしていた。
JavaScript で Google ログインを使用して認証する

こんな風に書かれていた。

# こうして
var provider = new firebase.auth.GoogleAuthProvider();

# こう
firebase.auth().signInWithRedirect(provider);

だから、こんな風にした。

firebase.auth().signInWithRedirect(new firebase.auth.GoogleAuthProvider());

動かない。以下のエラーたちが出た。

# これとか
Error: Cannot find the firebase namespace; be sure to include firebase-app.js before this library.

# これとか
Error in v-on handler: "TypeError: firebase.auth is not a function"

# これ
TypeError: firebase.auth is not a function

答え

こいつが不完全だった。
Firebase を JavaScript プロジェクトに追加する

<body>
  <!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services -->

  <!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
  <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-app.js"></script>

  <!-- Add Firebase products that you want to use -->
  <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-auth.js"></script>
  <script src="https://www.gstatic.com/firebasejs/6.2.0/firebase-firestore.js"></script>
</body>

以上。

0
0
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
0
0