Google api auth2 signOut not working Google api auth2 signOut not working angularjs angularjs

Google api auth2 signOut not working


I tried as following and it worked. It is required to call auth2.disconnect() when the auth2.signOut() success.

<script type="text/javascript">    function signOut() {        var auth2 = gapi.auth2.getAuthInstance();        auth2.signOut().then(function () {            auth2.disconnect();        });    }    function onLoad() {        gapi.load('auth2', function() {            gapi.auth2.init();        });    }</script><script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>


It can happen that the auth2 object is not loaded.( which would cause both issues presented in the question ).

This following snippet resolves that particular issue.

 if(!gapi.auth2){    gapi.load('auth2', function() {        gapi.auth2.init();    }); }