gapi , after user logout , refresh the page session storage gets cleared and gapi object is empty . hence unable to login back again

Viewed 138

I'm able to login and logout but once after i logout and refresh the page , in session storage https://accounts.google.com , data gets cleared as below cachedValue: {} cookieHash: "-366418662"

I tried to login again , gapi object is empty and returns null below is my code

for sign in :

      componentDidMount() {
         gapi.load('auth2',async()=>{
          await gapi.auth2.init({
          client_id: '***************',
        })
        var auth2 = await gapi.auth2.getAuthInstance();
        var profile =await auth2.currentUser.get().getBasicProfile();
        console.log('name',profile);
        gapi.load('signin2',async()=>{
          await gapi.signin2.render('loginButton', {
            'onsuccess': this.onSuccess,
            'onfailure': this.onFailure
          });
        })
      })
}

onSuccess=(googleUser)=>{
 console.log(googleUser)
}
onFailure=(err)=>{
 console.log(err)
}

render(){
  return(
              <div id="loginButton"  className="sc-login google" >
                  <div id="my-signin2"></div>
                  <img src={google} alt="" />
                </div>
  )  
}

signout.js / signout page code:

 var signIn=gapi.auth2.getAuthInstance().isSignedIn.get()
 if(signIn){
   await auth2.signOut();
 }

After i signout , session storage is present . but once when i do a refresh after signout and try to login back again , unable to login .

0 Answers
Related