Skip to content

Instantly share code, notes, and snippets.

@letswritetw
Created November 14, 2021 05:25
Show Gist options
  • Save letswritetw/f57ca45aecb2008ae3b1497e46b967b8 to your computer and use it in GitHub Desktop.
Save letswritetw/f57ca45aecb2008ae3b1497e46b967b8 to your computer and use it in GitHub Desktop.
firebase-auth-github
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