react-oauth
react-oauth copied to clipboard
onSuccess is not being called when I try to login with useGoogleLogin
Here is my demo component. When I try to login with google, it redirects to http://localhost:3000/sign-in with all google info in the url, but does not call onSuccess or onError functions. Please hekp to resolve the issue
import { useGoogleLogin } from '@react-oauth/google';
export const SignInPage = () => {
const login = useGoogleLogin({
onSuccess: tokenResponse => console.log(tokenResponse),
onError: () => {
console.log('Login Failed');
},
flow: 'auth-code',
ux_mode: 'redirect',
redirect_uri: 'http://localhost:3000/sign-in',
});
return (
<button type="button" onClick={() => login()}>
Google login
</button>
);
};
same issue for me
@Lenur29 did you find a solution?
My issue with this had to do with the COOP header being set to same-origin: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy. There is another callback called onNonOAuthError that you can hook into and console log to find out if it's dropping the popup prematurely.