I'm trying to use firebase auth with a blazor WASM which hosted in a github page.
I'm loading all needed JS from CDN on my index.html, looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
//lots of other stuff
</head>
<body>
//some blazor
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js";
import {
getAuth,
onAuthStateChanged,
GoogleAuthProvider,
signInWithPopup,
signOut,
} from "https://www.gstatic.com/firebasejs/9.15.0/firebase-auth.js";
import {
getFirestore,
collection,
addDoc,
query,
orderBy,
limit,
onSnapshot,
setDoc,
updateDoc,
doc,
serverTimestamp,
} from 'https://www.gstatic.com/firebasejs/9.15.0/firebase-firestore.js';
import {
getStorage,
ref,
uploadBytesResumable,
getDownloadURL,
} from 'https://www.gstatic.com/firebasejs/9.15.0/firebase-storage.js';
import { getMessaging, getToken, onMessage } from 'https://www.gstatic.com/firebasejs/9.15.0/firebase-messaging.js';
import { getPerformance } from 'https://www.gstatic.com/firebasejs/9.15.0/firebase-performance.js';
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyB3EobtWgtzNrOL2Qde3nM-JCfsPdAqRGg",
authDomain: "vikingarena-5fb20.firebaseapp.com",
projectId: "vikingarena-5fb20",
storageBucket: "vikingarena-5fb20.appspot.com",
messagingSenderId: "127848345256",
appId: "1:127848345256:web:d31f8969ea0806d04a1c9d"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
//other scripts
<script src="js/VikingJS.js"></script>
</body>
</html>
Then I have my VikingJS.js file where I try to do things, like google loging:
async function signIn() {
var provider = new Auth.GoogleAuthProvider();
await Auth.signInWithPopup(Auth.getAuth(), provider);
}
I call it from blazor using JSInterop, but I get: ReferenceError: GoogleAuthProvider is not defined
Here is the calling bit:
private async Task Login() {
await JSRuntime.InvokeVoidAsync("signIn");
}
How do I load all those methods from firebase to have them accessible in my js file?