google sign in in firebase react

//add to your firebase.js file: google provider sign-in
const googleProvider = new firebase.auth.GoogleAuthProvider();
export { firebase, db, auth, functions, googleProvider }

//Actions/GoogleAuthentication.js
import { firebase, googleProvider, db } from '../components/firebase/firebase'
import React, {useEffect} from "react";
import { useHistory, Redirect } from 'react-router-dom'

export const SignInWithGoogle = () => {
    const history = useHistory();
    useEffect(() => {
        setTimeout(() => {
            history.push('/dashboard');
         }, 10000);
       },[]);

    return () => {
        return firebase.auth().signInWithPopup(googleProvider)
        .then(async result =>{
            console.log(result.credential.accessToken)
            const user = result.user
            console.log(user)
            localStorage.setItem('userid', user.uid)
            localStorage.setItem('photoURL', user.photoURL)
            //TODO if userid exists IN USERS db then use update IF NULL use set
            await db.collection('users').doc(user.uid).update({
               // id: user.uid,
                name: user.displayName,
                email: user.email,
                phone: user.phoneNumber,
                photoURL: user.photoURL
            })
        })
        .then(() => {
            history.push('/dashboard');
        })
        .catch( err => {
            console.log(err)
        })       
    }
}

export const startLogout = () => {
    return () => {
        return firebase.auth().signOut()
    }
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
firebase google signin react firebase react sign in with google firebase auth react google sign google sign in firebase react firebase google sign in react firebase login google react first time firebase sign in with google in react add sign in with google to react with firebase react sign in with google with firebase google sign infirebase in react how to login using google with firebase in react authentication with google account firebase react login with google firebase react google sign in firebase example react google sign in using firebase on react webapp google login with firebase reactjs make google signin auth in react firebase react firebase signup and login with google reactjs google login with firebase google login authentication firebase react Sign in with google firebase react example react sign in with google firebase how to connect firebase signin with google with react how to coonect firebase signin with google with react sign in with google with firebase react google sign in react.js firebase auth with google firebase react google auth in react firebase how to sign up with google firebase react js how to sign up witj google firebase react js sign in with google firebase react js react firebase app with google login f how to sign in with googlein react firebase react authentication firebase signin login adding google sign in to react firebase sign in with google react native firebase how to use google sign in featur of firebase with react add google login to react firebase react sign with firebase google auth google firebase login in react firebase goole sign in with react firebase google sign in react tutorial how to add sign in using google in react js from firebase google login in react firebase firebase sign up with google react firebase sign in with google react react sign in withput google on firebase firebase google authentication react js signInWIthPopop google auth react native google sign in react firebase Firebase Google Sign in with React Authenticate Using Google Sign-In react js firebase google authentication react firebase web react google authentication firebase react native firebase google sign in firebase auth google sign in react react + firebase + google authentication latest sign in with google react firebase google provider auth type typescript firebase sign in with google react js firebase @react-firebase sign up google sign in react linkedin sign in with firebase react firebase authentication google sign in react firebase login with ggole react how to open a popup gogle sigin in crome when user is not login sign in with google rendering about.blank firebase firebase signin flow google sign in expo react native firebase sign in with googel firebase signInWithPopup firebase firebase function goes to google log in form how to javascript singin Firbase google login react google sign up login using firebase firebase google authentication web react flutter google signin with firebase google javascript firebase login api google sign in firebase flutter how to add continue with google firebase react react native firebase google login firebase login react firebase google sign in js react native signup and login firebase firebase email sign in google sign in without firebase react native react firebasui google auth firebase authentication email and password react react firebase email authentication auth google firebase and react access SigninWithGoogleClick error firebase sign in authorization javascript code firebase google signin in react and express register with google firebase reactjs singup with google firebase reactjs node firebase google signin firebase google login listen for google signin firebase login with google in react js how to authentication user with google account in react on firebase google signin firestore connect with gmail firebase google login with firebase in web firebase login with google react firebase google signin firebase google sign in needs refresh page firebase google sign in needs refreshed page google sign in with popup issues react firebase google sign in with popup needs refresh react firebase firebase sign in with google firebase google sign in check if is existing firebase sign in with redirect no users being show with google outh in firebase firebase react google login how to login with firestore in javascript change authorized domains firebase gmail login page firebase signup page react firebase express react signinwithpopup react js firebase auth google get user google firebase signin react js signup with google firebase react firebase auth google react react google login firebase add google login firebase react react js firebase auth google firebase using signinwithredirect firebase google signin in react app firebase login with google account react how to add firebase google signup to react app google auth firebase react firebase popup is user new firebase google login react react-google-login prevent multiple database inputs google login firebase react react and firebase google authentication google oauth in react firebase signinwithGoogle popup firebase google authentication react login with google button react firebase react firebase google authentication react js google auth firebase firebase google login react js react js firebase gmail auth how to use sign up with google react firebase why signinwithpop not working on android in firebase with reactjs for webapp How to redirect a user to its own account in javascript firebase real time databse google sign in with firebase with reactjs reactjs sign in with google firebase sign in with google firebase react implement google auth with firebase in react google signin in firebase react react google sign in firebase firebase react google authentication firebase web authentication with react and google and node firebase web authentication with react and google nodejs firebase signinwithgoogle authentication sign in with google firebase firebase google auth react react firebase google login firebase google sign in react js how to do oauth with firebase and react react firebase google sign in firebase login with google react firebase google authentication idtoken where to find react google javascript sign in doesn't fire firebase loginbygmail redirect sign in with google authenticator firebase react google firebase sign in firebase email login in web react.ja google firebase authentication react firebase create user with signInWithPopup authenticate firebase react google firebase google sign in google login with firebase react block google sign in firebase react react firebase login with google react firebase sign in with google firebase doesn't load gogle accounts wityh googleAuthProvider google sign in in firebase react
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source