Created
November 14, 2021 05:25
-
-
Save letswritetw/f57ca45aecb2008ae3b1497e46b967b8 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, getRedirectResult, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
getRedirectResult(auth) | |
.then((result) => { | |
const credential = GithubAuthProvider.credentialFromResult(result); | |
if(credential) { | |
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