I use React-google-login to sign up and log in with a google account in my app
I use a client id to test it.
this is my login component import:
<GoogleLogin
icon={false}
className="input-rounded d-flex"
clientId="....."
onSuccess={() => handleGoogleSignUp}
onFailure={() => handleGoogleSignUp}
cookiePolicy={"single_host_origin"}
>
<div
role="button"
className="m-0 google-signin d-flex"
>
img src={vector} alt="vector" className="me-2" />
<div>Sign up with Google</div>
</div>
</GoogleLogin>
this is my function:
const handleFailure = (err) => {
console.log(err);
};
const handleSucsess = (res) => {
console.log(res);
}
but when click on the google button the popup close immediately and I can't choose one account can anybody help me?
Try to pass in the response as mentioned here in the official package documentation Visit https://www.npmjs.com/package/react-google-login
const responseGoogle = (response) => {
console.log(response);
}
ReactDOM.render(
<GoogleLogin
clientId=""
buttonText="Login"
onSuccess={responseGoogle}
onFailure={responseGoogle}
cookiePolicy={'single_host_origin'}
isSignedIn={true} //Keeps user signed in
/>,
document.getElementById('googleButton')
);