Google+ output without popup

I have a submit button on my page that I run like this:

$('#logout').click(function() {
    gapi.auth.signIn({
        'callback': function(authResult) {
            if (authResult['status']['signed_in']) {
                gapi.auth.signOut();
            } else {
                // second pass, signout succesful
            }
        }
    })
});

      

This results in two calls to Google (first to confirm that the user is already registered, the second to log out), so the two codes go through the callback code. This also causes the Google+ login window to pop up briefly.

Is there a way to just call gapi.auth.signOut () directly without the signIn step? I have a Google+ user ID (as well as an access_token) if that helps.

+3


source to share


1 answer


You don't need to call gapi.auth.signIn () every time you want to exit. just call gapi.auth.signOut () from anywhere to initiate the logout process of your app (but still logged into Google on other tabs, which is good practice).

An example would be to simply attach a gapi.auth.signOut () event to the onclick event on a button;



<button onclick="gapi.auth.signOut();">Sign out</button>

      

+1


source







All Articles