google sign in in firebase react
JavaScript
//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()
}
}
Also in JavaScript:
- Title
- crypto.com api
- Category
- JavaScript
- Title
- how to dynamically add mp3 files in jquery player
- Category
- JavaScript
- Title
- how to link javascript to html
- Category
- JavaScript
- Title
- enter ascii code in javascript
- Category
- JavaScript
- Title
- array of images javascript
- Category
- JavaScript
- Title
- how to add ' in javascript string
- Category
- JavaScript
- Title
- create csv file javascript
- Category
- JavaScript
- Title
- angularjs filter array of objects based on name prop
- Category
- JavaScript
- Title
- cascading dropdown for forms react
- Category
- JavaScript
- Title
- javascript change class of item
- Category
- JavaScript
- Title
- convert object to array javascript
- Category
- JavaScript
- Title
- javascript circular evaluation
- Category
- JavaScript
- Title
- javascript array map stack
- Category
- JavaScript
- Title
- fetch api javascript
- Category
- JavaScript
- Title
- get location from brwoser react
- Category
- JavaScript
- Title
- javascript calculator
- Category
- JavaScript
- Title
- how to pretty formatjson value on terminal ruby
- Category
- JavaScript
- Title
- angularjs iframe src binding
- Category
- JavaScript
- Title
- check if file exists javascript
- Category
- JavaScript
- Title
- change title react
- Category
- JavaScript
- Title
- javascript check for duplicates in array
- Category
- JavaScript
- Title
- how to run cypress
- Category
- JavaScript
- Title
- javascript check if variable is object
- Category
- JavaScript
- Title
- check the doc name in javascript
- Category
- JavaScript
- Title
- age calculator javascript
- Category
- JavaScript
- Title
- axios post data vue js
- Category
- JavaScript
- Title
- "when.promise" async await
- Category
- JavaScript
- Title
- how to get nth fibonacci javascript
- Category
- JavaScript
- Title
- client timezone offset in JavaScript
- Category
- JavaScript
- Title
- Code is valid JSON equivalent of the key/value pair shown that also preserves the original value: UPC: 043875
- Category
- JavaScript
- Title
- javascript change web page title
- Category
- JavaScript
- Title
- how to position View absolute react native
- Category
- JavaScript
- Title
- how to remove spaces from strings javascript
- Category
- JavaScript
- Title
- how to add onclick event in javascript
- Category
- JavaScript
- Title
- express redirect
- Category
- JavaScript
- Title
- creating a 2d array in js
- Category
- JavaScript
- Title
- dom create element
- Category
- JavaScript
- Title
- how to detect a keypress in javascript
- Category
- JavaScript
- Title
- append after element jquery
- Category
- JavaScript
- Title
- how to send enter event to input field jquery
- Category
- JavaScript
- Title
- global site tag (gtag.js) - google analytics gatsby
- Category
- JavaScript
- Title
- click point invert zoom react simple map
- Category
- JavaScript
- Title
- add discord.js library
- Category
- JavaScript
- Title
- express ejs
- Category
- JavaScript
- Title
- add month date now javascript
- Category
- JavaScript
- Title
- arrow function javascript ie11
- Category
- JavaScript
- Title
- add image in react native
- Category
- JavaScript
- Title
- how to have a function inside useeffect
- Category
- JavaScript
- Title
- create array from htmlcollection
- Category
- JavaScript
- Title
- bind in javascript
- Category
- JavaScript
- Title
- how to take value from html text box using parseint javascript
- Category
- JavaScript
- Title
- angular date formats
- Category
- JavaScript
- Title
- accept 2 values after decimal in angular forms
- Category
- JavaScript
- Title
- check a checkbox jquery
- Category
- JavaScript
- Title
- how to create a new react native project
- Category
- JavaScript
- Title
- how to get element by title js
- Category
- JavaScript
- Title
- get url params angular
- Category
- JavaScript
- Title
- express server replit
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- casl react
- Category
- JavaScript
- Title
- importing project images in react native
- Category
- JavaScript
- Title
- datetime to date javascript
- Category
- JavaScript
- Title
- enter event in jquery
- Category
- JavaScript
- Title
- 'react-scripts' n’est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.
- Category
- JavaScript
- Title
- is forEach sync js
- Category
- JavaScript
- Title
- $(document).on in javascript
- Category
- JavaScript
- Title
- how to append select option in jquery
- Category
- JavaScript
- Title
- how do i backspace from javascript calculator
- Category
- JavaScript
- Title
- insertion sort js
- Category
- JavaScript
- Title
- how to access router from the store vue
- Category
- JavaScript
- Title
- get current screen name react navigation
- Category
- JavaScript
- Title
- create an element jquery
- Category
- JavaScript
- Title
- how to count click events javascript
- Category
- JavaScript
- Title
- how to create component in reactjs
- Category
- JavaScript
- Title
- immediate invoke function js
- Category
- JavaScript
- Title
- gsap
- Category
- JavaScript
- Title
- how to run p5js in a particular section of page
- Category
- JavaScript
- Title
- angular onchange event
- Category
- JavaScript
- Title
- how to change node version
- Category
- JavaScript
- Title
- include javascript jquery file in html
- Category
- JavaScript
- Title
- how to host react app on heroku
- Category
- JavaScript
- Title
- all ajaxcomplete event
- Category
- JavaScript
- Title
- href back page javascript
- Category
- JavaScript
- Title
- Cannot find module '.json'
- Category
- JavaScript
- Title
- javascript check if undefined or null or empty string
- Category
- JavaScript
- Title
- going through every attributes of an object javascript
- Category
- JavaScript
- Title
- blob to text javascript
- Category
- JavaScript
- Title
- how to generate random string in javascript
- Category
- JavaScript
- Title
- clear scene\
- Category
- JavaScript
- Title
- javascript checkbox checked
- Category
- JavaScript
- Title
- ajax request qml
- Category
- JavaScript
- Title
- choose random from array javascript
- Category
- JavaScript
- Title
- how to draw a flower in javascript
- Category
- JavaScript
- Title
- import reactdom
- Category
- JavaScript
- Title
- javascript check empty object
- Category
- JavaScript
- Title
- javascript Clone an array
- Category
- JavaScript
- Title
- declare array in javascript
- Category
- JavaScript
- Title
- ckeditor change value
- Category
- JavaScript
- Title
- async await catch error
- Category
- JavaScript
- Title
- alternate color to table row jquery
- Category
- JavaScript