'React google login silently failing
const onGoogleLoginFailure = () => {
console.log("failed");
};
const onGoogleLoginSuccess = useCallback((response) => {
const idToken = response.tokenId;
console.log("WHY ARE YOU LIKE THIS");
fetch("/api/auth/", {
method: "GET",
headers: {
Authorization: idToken,
},
}).then((res) => console.log(res));
// .then((_) => navigate("/overview"))
}, []);
return isLoading ? null : (
<Flex alignItems="center" justifyContent="center" h="100vh">
<GoogleLogin
clientId="tokenBOI" // your Google app client IDđ
onSuccess={onGoogleLoginSuccess}
onFailure={() => onGoogleLoginFailure}
disabled={false}
render={(renderProps) => {
return (
<Button onClick={renderProps.onClick}>
Login
</Button>
);
}}
/>
</Flex>
);
As stated, this code above fails silently and triggers onFailure. The id token is valid, the scope is inside one org. The prompt to select an account opens up, I select the account, the prompt closes and then nothing happens.
Solution 1:[1]
try these
const LoginFailure = (response) => {
console.log(response)
swal('Login fail')
}
and call Function onFailure={LoginFailure }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rian yunandar |