react-google-login抛出错误“用户关闭了pop_up”

问题描述

我正在使用react-google-login在我的项目中使用google登录,但是当我使用chrome浏览器时,它抛出“ pop_up被用户关闭错误,并且弹出窗口被关闭。我尝试清除缓存,但是我想要对此的永久解决方案。 下面是我的代码


async googleLogin(res) {
    
      const {social_login_user} = this.state
      let postData;
      if (res.error == undefined && res.profileObj.imageUrl) {
        let email= res.profileObj.email
        let img_url = res.profileObj.imageUrl
        let response_img = await axios.get(img_url,{
          responseType: 'arraybuffer'
        })
        const base64 = "data:image/jpeg;base64,"+new Buffer(response_img.data).toString('base64')
        var random_number = Math.floor(1000 + Math.random() * 9000);
        let generated_username = email.substring(0,email.lastIndexOf("@")).substring(0,12)+random_number
        postData = {
          name: res.profileObj.name,email: email,image:res.profileObj.imageUrl,username: generated_username,type:'google',image_base64: base64
        }
          
          this.setState({
            social_login_user: {
              ...social_login_user,...postData,custom_username:'',profile_image:"social_image",profile_username:"social_username"},image_warning:''
          },()=>{
            axios({
              url: API_URL+"user/checkuserexistance",method:"post",data:{
                email:email
              }
            }).then(response=>{
              if(response.data.status==200){
                this.setState({
                  show_social_login_Box: !response.data.user_exist
                })
                if(response.data.user_exist){
                  this.props.dispatch(loginWithSocialAccount(this.state.social_login_user))
                }
              }
              //console.log(response)
            }).catch(error=>{

            })
          })
       }  
   }
          
 <GoogleLogin
 clientId={googleClientId}
 buttonText="Login with Google"
 onSuccess={ this.googleLogin}
 onFailure={ this.googleLogin}
                            
 />

如果有人有任何建议或可以帮助我解决这个问题,我将非常感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)