I’ve been trying to get authentication to work on my firebase wep app however I am running into this issue, any help would be greatly appreciated, leaving a copy of my code below.
# JS
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.11.1/firebase-app.js";
import { getAuth, createUserWithEmailAndPassword, GoogleAuthProvider, signInWithRedirect,
signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/10.11.1/firebase-auth.js";
import { getDatabase, set, ref } from "https://www.gstatic.com/firebasejs/10.11.1/firebase-database.js";
omitted the config
const firebaseConfig = {
apiKey: "AIzaSyDj5gayMeO7LlMYkLKlMojXuBzLLa46H7I",
authDomain: "domain is actual domain url ",
databaseURL: "database url (is the actual url in live code",
projectId: "",
storageBucket: "",
messagingSenderId: "542508426520",
appId: "1:542508426520:web:fa17e971eb43be4c8e6a6d",
measurementId: "G-DEMX9X0NYE"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const provider = new GoogleAuthProvider();
const db = getDatabase(app)
// inputs
// register
const register = document.getElementById('register');
function regUser(){
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
console.log(email, password)
alert("Account Creation In Progress")
createUserWithEmailAndPassword(auth, email.value, password.value)
.then((userCredential) => {
// Signed up
const user = userCredential.user;
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// ..
});
}
register.addEventListener('click', regUser);
const login = document.getElementById('login');
login.addEventListener("click", function(event){
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
});
})
I’ve made sure that signing in with email and password is enabled on my firebase console, first time using firebase so still learning the ropes of trouble shooting. I’ve had a look for any tutorials on youtube however they aren’t helping as each time i try i get the same error
New contributor
Shane Honnor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.