はじめに
こんなことをやろうとしていた。
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>
以上。