'react-google-login not calling onSuccess
In the following snippets I'm trying to implement google oauth into my webapp using npm react-google-login. When I try to sign-in, the popup appears, I select one of my accounts, then a loading circle appears and the popup closes. (Not sure if this is a crash). However, my googleSuccess function does not seem to be called as none of the things I've logged are appearing in the console. Closing the popup prematurely does log googleError in onFailure. Does anyone know why my onSuccess callback might not be firing?
const googleSuccess = async (res) => {
console.log("In googlesuccess");
try {
console.log("G sign in success", res);
} catch (err) {
console.error(err);
}
};
const googleError = (err) => {
console.error('Google sign in failed.', err);
};
<GoogleLogin
clientId= //removed, but my client id is here in my actual code
render={(renderProps) => (
<Button className={classes.googleButton} color="primary" fullWidth onClick={renderProps.onClick} disabled={renderProps.disabled} startIcon={<Icon />} variant="contained">
Google Sign In
</Button>
)}
onSuccess={googleSuccess}
onFailure={googleError}
cookiePolicy="single_host_origin"
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|