用于退出问题的Google JavaScript SDK

时间:2018-04-12 05:55:29

标签: javascript google-api sdk logout


我正在尝试使用标准的Google JavaScript SDK进行注销

function googleLogout() {
  var auth2 = gapi.auth2.getAuthInstance();
  auth2.signOut().then(function () {
    console.log('User signed out.');
  });   
} 

执行时没有任何错误,并显示“用户退出”,但不从gmail注销用户(或任何谷歌在另一个标签中登录)

1 个答案:

答案 0 :(得分:0)

您需要首先加载您的库,确保它已加载

<script src="https://xxxx"></script>
<script>
      function googleLogout() {
            var auth2 = gapi.auth2.getAuthInstance();
            auth2.signOut().then(function () {
                console.log('User signed out.');
            });
        }
</script>