Created
November 14, 2021 05:22
-
-
Save letswritetw/c2c08e18a2427991319efa5c1090f5be to your computer and use it in GitHub Desktop.
firebase-auth-github
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, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
signInWithPopup(auth, providerGithub) | |
.then((result) => { | |
const credential = GithubAuthProvider.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 = GithubAuthProvider.credentialFromError(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment