Skip to content

Instantly share code, notes, and snippets.

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