Google api 谷歌API注销不起作用

Google api 谷歌API注销不起作用,google-api,google-oauth,google-login,Google Api,Google Oauth,Google Login,我集成了google登录api,它工作正常,但注销时出错。注销过程不起作用。登录的用户在单击注销链接功能后将不会注销。 这是我的代码: 函数onSignIn(谷歌用户){ var profile=googleUser.getBasicProfile(); 如果(profile.getEmail()!=“”){ var myKeyVals={token:googleUser.getAuthResponse().id_token} $.ajax({ 类型:“POST”, url:“validate

我集成了google登录api,它工作正常,但注销时出错。注销过程不起作用。登录的用户在单击注销链接功能后将不会注销。 这是我的代码:


函数onSignIn(谷歌用户){
var profile=googleUser.getBasicProfile();
如果(profile.getEmail()!=“”){
var myKeyVals={token:googleUser.getAuthResponse().id_token}
$.ajax({
类型:“POST”,
url:“validate.php”,
数据:myKeyVals,
数据类型:“文本”,
成功:功能(数据){
window.location=“page”;
}
});
}
}
函数签出(){
var auth2=gapi.auth2.getAuthInstance();
auth2.signOut().then(函数(){
});
}
此处,注销js功能不起作用,页面将自动重新加载并转到adminpage。


提前谢谢。

这对我很有用,而不是你可以添加你的域名


document.location.href=”https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://localhost/application-姓名/登录用户”这对我很有效。完整的JS函数代码。
星号只是一个示例,说明了如何在执行注销后定义要重定向到的URL

注销
函数myFunction(){
location.href=https://accounts.google.com/Logout?&continue=http://******.com/”;
}
这对我很有用

只需按如下方式修改签出函数,这里请仔细注意,reload()方法用于在签出后立即重新加载当前文档。

<button onclick="myFunction()">Sign Out</button>

<script>
function myFunction() {
    gapi.auth2.getAuthInstance().signOut().then(function () {
      console.log('User signed out.');
      location.reload();
    });

}
</script>
注销
函数myFunction(){
gapi.auth2.getAuthInstance().signOut().then(函数(){
log('User signed out');
location.reload();
});
}
这可能会有所帮助

const onGoogleSignOut=()=>{
//使用google注销重定向
//location.href='document.location.href='https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue='+window.location.href;
var auth2=gapi.auth2.getAuthInstance();
auth2.signOut()
.然后(函数(){
auth2.disconnect();
log('User signed out');
//location.reload();
});

}
Hm。我也做了同样的事情(只是还没有登录功能),注销对我来说很好。如果您从浏览器的任何窗口自动注销,您的所有会话都将被终止。