首页 > 解决方案 > Google O Auth 在本地服务器上工作,但在 nelify 上部署后没有(每次都调用 onFailure)

问题描述

谷歌登录失败..

<GoogleLogin
                    clientId="id from google o auth "
                    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={googleFailure}
                    cookiePolicy="single_host_origin"
                />

const googleSuccess = async (res) => {
    const result = res?.profileObj;
    const token = res?.tokenId;
    try {
        dispatch({type: "AUTH", data: {result, token}})
        history.push("/");
    } catch (error) {
        console.log(error)
    }
} 
const googleFailure = () => {
    console.log("Google Login Failure...")

在 netlify 上部署时,google oAuth 出现错误。我已经在 Google Console Api 凭据中添加了 URL 和重定向,但是每次按下按钮并点击任何电子邮件时,仍然有 onFailure 功能正在运行......

标签: reactjsmongodbexpressdeploymentnetlify

解决方案


推荐阅读