Google API Signout无效

San*_*ith 3 google-api google-login google-oauth

我集成谷歌登录api和它工作正常但登出时出错.登出过程不起作用.登录用户点击退出链接功能后不会退出.这是我的代码:

<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>
Run Code Online (Sandbox Code Playgroud)

这里signOut js功能不起作用,页面将自动重新加载并转到adminpage. 这是我的文件.

提前致谢.

Mah*_*kos 7

这适用于我而不是http:// localhost/application-name/logoutUser,您可以添加您的域名

document.location.href = "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://localhost/application-name/logoutUser";
Run Code Online (Sandbox Code Playgroud)