Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Created October 13, 2019 13:13
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 luandevpro/94fe54e1d3037e4a0a1b0ea6ee831974 to your computer and use it in GitHub Desktop.
Save luandevpro/94fe54e1d3037e4a0a1b0ea6ee831974 to your computer and use it in GitHub Desktop.
...
import { auth, providerGoogle } from '../lib/firebase';
function Index() {
...
const handleAuth = () => {
auth.signInWithPopup(providerGoogle).then((result) => {
console.log(result);
});
};
useEffect(() => {
auth.onAuthStateChanged((user) => {
if (user) {
auth.currentUser.getIdToken(true).then((token) => {
console.log(token);
});
}
});
}, []);
return (
<div className="container mt-5">
<button type="button" className="mt-5 mb-5 btn btn-primary" onClick={handleAuth}>
Google
</button>
...
</div>
);
}
export default withRedux(Index);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment