Open App.js and import GoogleLogin from package
import GoogleLogin from 'react-google-login';
Now just add Google Login button with Client ID
clientId="Your_own_client_ID.googleusercontent.com"
buttonText="Login with Google"
onSuccess={pass}
onFailure={fail}
cookiePolicy={'single_host_origin'}
/>
Just add two handles for onSuccess
const fail = (result) =>{
alert(result.error);
}
and for onFailure
const pass = (googleData)=>{
console.log(googleData);
}
Read more: https://easycodesardar.blogspot.com/2021/11/login-with-google-reactjs.html
Top comments (0)