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

GoogleLogout component does not work. #507

Open ag2byte opened 2 years ago

ag2byte commented 2 years ago

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.

saadullah01 commented 2 years ago

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.

ag2byte commented 2 years ago

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

Ankan002 commented 2 years ago

Can you please mention more steps of implementation

ag2byte commented 2 years ago

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)
    })
Ankan002 commented 2 years ago

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: @.***>