react-google-login icon indicating copy to clipboard operation
react-google-login copied to clipboard

GoogleLogout component does not work.

Open ag2byte opened this issue 2 years ago • 5 comments

I am tying to use the GoogleLogout component as mentioned in the documentation, but it does not seem to work. Following is my implementation

function LogoutButton(){
    const onSuccess = ()=>{
        console.log('Log out successfull');
        // setLoggedIn(false)
    }
    const onFailure = ()=>{
        console.log('Log out unsuccessfull');
    }
    return (
        
         <GoogleLogout   
             clientId={process.env.REACT_APP_GOOGLE_CLIENT_ID}
             buttonText="Log Out"
             onLogoutSuccess={onSuccess}
             onFailure={onFailure}
            />
        )}

Neither the onLogoutSuccess nor the onFailure is working.

ag2byte avatar Apr 15 '22 07:04 ag2byte

For me it shows this in the console:

glapi

Maybe it's because that the "Sign In With Google Javascript API" has been updated on 12th April and it has not been updated in react library that we are using.

saadullah01 avatar Apr 17 '22 09:04 saadullah01

Maybe this is the issue. I had to use gapi script to get around this for my use case

ag2byte avatar Apr 18 '22 07:04 ag2byte

Can you please mention more steps of implementation

Ankan002 avatar Apr 24 '22 12:04 Ankan002

I used the following hook at the parent component. I am not sure if this is the best way to do so, but it works.

 useEffect(()=>{
        function start()
        {
            gapi.client.init({
                clientId:process.env.REACT_APP_GOOGLE_CLIENT_ID,
                scope:""
            })
        }
        gapi.load('client:auth2',start)
    })

ag2byte avatar Apr 25 '22 07:04 ag2byte

Okk that's quite interesting.

On Mon, Apr 25, 2022 at 1:07 PM Abhigyan Gautam @.***> wrote:

I used the following hook at the parent component. I am not sure if this is the best way to do so, but it works.

useEffect(()=>{ function start() { gapi.client.init({ clientId:process.env.REACT_APP_GOOGLE_CLIENT_ID, scope:"" }) } gapi.load('client:auth2',start) })

— Reply to this email directly, view it on GitHub https://github.com/anthonyjgrove/react-google-login/issues/507#issuecomment-1108188031, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO3WLO7XEC2G4U6C5DQFKDVGZDSLANCNFSM5TPYJMCA . You are receiving this because you commented.Message ID: @.***>

Ankan002 avatar Apr 25 '22 07:04 Ankan002