Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API Signout Not working

I integrate google login api and It works fine but there is an error in logout.The sign out process is not working.The logged user will not sign out after click the sign out link function. This is my code:

<meta name="google-signin-client_id" content="here my api .apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<a href="javascript:signOut()">Sign Out</a>
<script>
function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
     if(profile.getEmail()!="") {
      var myKeyVals = { token : googleUser.getAuthResponse().id_token }
      $.ajax({
        type: "POST",
        url: "validate.php",
        data: myKeyVals,
        dataType: "text",
        success : function(data) {
            window.location = "page";
        }
      });
    }
  }

  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
    });
  }
</script>

Here signOut js function is not working and the page will auto reload and go to adminpage. This is my document.

Thanks in advance.

like image 328
Sankar Smith Avatar asked Apr 26 '17 06:04

Sankar Smith


1 Answers

this works for me instead of http://localhost/application-name/logoutUser you can add your domain name

document.location.href = "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://localhost/application-name/logoutUser";
like image 188
Mahendra Waykos Avatar answered Oct 15 '22 13:10

Mahendra Waykos