React.js 中的 Google 登录返回 {error: 'popup_held_by_user'}

问题描述 投票:0回答:1

`我尝试使用React.js实现Google登录,但遇到了错误。错误信息如下: {错误:'popup_close_by_user'}

import React from 'react';
import { GoogleLogin } from 'react-google-login';

const clientId = "your-client-id";

function Login () {
    const onSuccess = (response) => {
        console.log("Login Success:", response);
    }

    const onFailure = (response) => {
        console.log("Login Failed:", response);
    }
  
    return(
        <div>
            <GoogleLogin 
                clientId={clientId}
                buttonText="Login with Google"
                onSuccess={onSuccess}
                onFailure={onFailure}
                cookiePolicy={'single_host_origin'}
                isSignedIn={true}
            />
        </div>
    )
}


`

reactjs google-api google-signin
1个回答
0
投票

我想指出,您正在使用的 react-google-login 软件包已被弃用。我强烈建议使用另一个包以确保兼容性和持续支持。

现在关于 {error: 'popup_angled_by_user'} 错误消息,这通常发生在用户在完成身份验证过程之前关闭 Google 身份验证弹出窗口时。最常见的原因中的另一个原因是浏览器阻止弹出窗口。 检查您的浏览器设置以确保允许您的 React 应用程序弹出窗口。

希望这对您有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.