Javascript 登录使用google plus在网站上注销

Javascript 登录使用google plus在网站上注销,javascript,html,Javascript,Html,我想使用google plus登录/注销wesite,下面是我的代码 使用google plus登录 函数onSignIn(谷歌用户){ var profile=googleUser.getBasicProfile(); console.log('ID:'+profile.getId());//不要发送到后端!改用ID令牌。 log('Name:'+profile.getName()); log('Image URL:'+profile.getImageUrl()); console.log(

我想使用google plus登录/注销wesite,下面是我的代码


使用google plus登录
函数onSignIn(谷歌用户){
var profile=googleUser.getBasicProfile();
console.log('ID:'+profile.getId());//不要发送到后端!改用ID令牌。
log('Name:'+profile.getName());
log('Image URL:'+profile.getImageUrl());
console.log('Email:'+profile.getEmail());//如果“Email”作用域不存在,则此值为null。
$(“#注销”).show();
}
函数签出(){
var auth2=gapi.auth2.getAuthInstance();
auth2.signOut().then(函数(){
log('User signed out');
});
}

但问题是signin工作得很好,但当我尝试注销时,它将不工作,控制台消息将显示,但不会注销


是否正在退出您的应用程序?如果是的话,这就是它应该做的,只从你的应用程序中注销,而不是从你浏览器中的谷歌上注销。如果要设置注销所有应用程序,需要删除身份验证令牌。是的,我想从web应用程序注销,那么如何删除身份验证令牌?请尝试以下操作:
<html>
<meta name="google-signin-client_id" content="fsdfsdf.apps.googleusercontent.com">
<title>Login With google plus</title>    
<script src="jquery.min.js"></script>
<script src="https://apis.google.com/js/client:platform.js" async defer></script>

<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script>
    function onSignIn(googleUser) {
        var profile = googleUser.getBasicProfile();
        console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
        console.log('Name: ' + profile.getName());
        console.log('Image URL: ' + profile.getImageUrl());
        console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
        $('#signout').show();
    }
</script>
<a href="#" id="signout" onclick="signOut();" style="display: none;">Sign out</a>
<script>
    function signOut() {
        var auth2 = gapi.auth2.getAuthInstance();
        auth2.signOut().then(function () {
            console.log('User signed out.');
        });
    }
</script>