简体   繁体   中英

Google+ signin signs user out

I am experiencing a problem when a user is logged in to more than one Google account.

My application has a login page with a Google+ signin button.

The user clicks the button and authorises the application.

The signinCallback is fired correctly. The app then renders a new page, which has a hidden signin button (to allow the user to sign out). When this page is rendered, the signinCallback is fired again, but with "user_signed_out" in the error field. The status contains:

google_logged_in: true
method: null
signed_in: false 

I don't see a way of handling this error.

Anybody else experienced this issue?

I think you're not revoking the access token you requested. If youre using javascript use this. Revoking the access token will allow you to request another token for other user.

        var revokeUrl = 'https://accounts.google.com/o/oauth2/revoke?token=' + access_token;
        $.ajax({
            type: 'GET',
            url: revokeUrl,
            async: false,
            contentType: "application/json",
            dataType: 'jsonp',
            success: function(nullResponse) {
                //do logout call back here

            },
            error: function(e) {
               console.log(e);
            }
        });

The problem seems to be that although I have included A signin button on both pages, it is not the same signin button. It seems that when a user initially signed in, that state is saved in the signin button on that page . So when the app navigates away from the page with that signin button, strange things happen. Another issue I have faced as a result of the same issue is that the user is unable to sign out.

Add another button for sing out. Than on click just call

gapi.auth.signOut();

It can be any button, look here .

I had the exactly same problem on my test site when i was doing the following

testsite.com

however when i changed it to www.testsite.com it worked perfectly and flawlessly.

Please make sure that you guys have the proper sub domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM