Created
November 10, 2021 12:42
-
-
Save letswritetw/37a60e9c7a078157655c0a285270e9ba to your computer and use it in GitHub Desktop.
firebase-auth-google-fb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGoogle = new GoogleAuthProvider(); | |
signInWithPopup(auth, providerGoogle) | |
.then((result) => { | |
const credential = GoogleAuthProvider.credentialFromResult(result); | |
const token = credential.accessToken; | |
const user = result.user; | |
}).catch((error) => { | |
const errorCode = error.code; | |
const errorMessage = error.message; | |
const email = error.email; | |
const credential = GoogleAuthProvider.credentialFromError(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment