anthonyjgrove / react-google-login

A React Google Login Component
https://anthonyjgrove.github.io/react-google-login
MIT License
1.84k stars 427 forks source link

This document requires 'TrustedScript' assignment. #527

Open 123roger456 opened 2 years ago

123roger456 commented 2 years ago

This document requires 'TrustedScript' assignment. Uncaught TypeError: Failed to execute 'setTimeout' on 'Window': This document requires 'TrustedScript' assignment. at XMLHttpRequest.onreadystatechange (:44:15)

These are the errors that are shown in my console when I try to use this package. This error is only appearing on my chrome browser and not coming on any other.

import { GoogleLogin } from 'react-google-login'
import { gapi } from 'gapi-script';

const Auth = () => {
useEffect(() => {
    function start() {
    gapi.client.init({
    clientId : "clientId",
    scope : 'email'
    })
    };
    gapi.load('client:auth2',start);
    });

  const googleSuccess = async (res) => {
    console.log(res)
  }
  const googleFailure = async (err) => {
    console.log(err)
  }
return (
 <GoogleLogin 
                clientId='clientId'
            onSuccess={googleSuccess}
            onFailure={googleFailure}
                render={(renderProps) => (
              <Button className={classes.googleButton} color="primary" fullWidth onClick={renderProps.onClick} disabled={renderProps.disabled} startIcon={<Icon />} variant="contained">
                Google Sign In
              </Button>
            )}
            cookiePolicy={'single_host_origin'}
            />
)
}

export default Auth

Please help me here. Anyone who helps me will be widely appreciated among all those who have encountered this same error.

roman-hrybinchuk commented 2 years ago

I have the same issue