Hola que tal, soy nuevo en programación, nuevo en Firebase, y estoy creando una app para
servicios de domicilio, comencé creando un titulo y un botón de inicio de sesión como lo explican en este video (
https://www.youtube.com/watch?v=e6aoUnLQBAw), pero cuando le doy iniciar sesión, sale este error "Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined
at app.js:2".
Alguien podría guiarme en el extenso mundo de firebase para lograr mi meta.
Hi, how are you, I'm new to programming, new to Firebase, and I'm creating an app for home services, I started creating a title and a login button as explained in this video (
https://www.youtube.com / watch? v = e6aoUnLQBAw), but when I log in, this error comes out "Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined
at app.js: 2 ".
Someone could guide me in the vast world of firebase to achieve my goal.
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Mi app</title>
</head>
<body>
<h1>Inicia sesión</h1>
<button id="login">
Inicia con Google
</button>
<div id="root"></div>
<script
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<!-- TODO: Add SDKs for Firebase products that you want to use
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyD0vTddupWWTdgarT0f51zMhBN_gs1fVKQ",
projectId: "manicure-74e82",
messagingSenderId: "150608947733",
appId: "1:150608947733:web:d7ba49832bdce127f17c1c",
measurementId: "G-LJ23HB8BNQ"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script src="app.js"></script>
</body>
</html>
Código App.js
//login
var provider = new firebase.auth.GoogleAuthProvider();
$('#login').click(function(){
firebase.auth()
.signInWithPopup(provider)
.then(function(result) {
var credential = firebase.auth.GoogleAuthProvider.credential(
googleUser.getAuthResponse().id_token);
firebase.auth().signInWithCredential(credential)
console.log(result.user);
});
});