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>
);
如前所述,上面的代码静默失败并触发onFailure。id标记有效,范围在一个组织内。选择帐户的提示打开,我选择帐户,提示关闭,然后什么也没发生。
3条答案
按热度按时间bttbmeg01#
react-google-login包正在被弃用的过程中,这就是为什么认证过程失败。我面临着同样的问题,所以显然我们必须使用react-oauth/google包进行认证,所以这值得一看。检查https://www.npmjs.com/package/@react-oauth/google了解更多细节。
nhaq1z212#
试试这些
并调用函数onFailure={登录失败}
v1l68za43#
我有同样的问题,并没有改变尝试新的软件包: