forked from mansiruhil13/Bobble-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Firebase.js
39 lines (36 loc) · 1.57 KB
/
Firebase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.14.1/firebase-app.js";
import { getAuth, GoogleAuthProvider, signInWithPopup } from "https://www.gstatic.com/firebasejs/10.14.1/firebase-auth.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBKWr4Q0_bTP-9-dnviFlyesJITE1K9LxI",
authDomain: "bobble-ai-6c878.firebaseapp.com",
projectId: "bobble-ai-6c878",
storageBucket: "bobble-ai-6c878.appspot.com",
messagingSenderId: "389012742453",
appId: "1:389012742453:web:f212dbd734d078e5b02c7c"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
auth.languageCode = 'en';
const provider = new GoogleAuthProvider();
const google_login = document.getElementById("google_btn")
google_login.addEventListener('click', () => {
signInWithPopup(auth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
// The signed-in user info.
const user = result.user;
console.log(user)
window.location.href = "index.html"
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// ...
});
})