Skip to content

Instantly share code, notes, and snippets.

@letswritetw
Created November 10, 2021 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letswritetw/37a60e9c7a078157655c0a285270e9ba to your computer and use it in GitHub Desktop.
Save letswritetw/37a60e9c7a078157655c0a285270e9ba to your computer and use it in GitHub Desktop.
firebase-auth-google-fb
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