2

As per google doc: When the google sign in button is loaded, it immediately checks to see if the user has authorized the application. This check is called "immediate mode" and if successful, the Google servers return an access token and pass a new authorization result object to the callback. If the button cannot make an immediate-mode authorization, the user must click the sign-in button to trigger the access flow.

My Google Plus signin button is part of header and on logout the home page is loaded,It again renders google plus button resulting in automatic login. User is never logged out due to this. How is it possible to allow login when when G Plus button is clicked and not when when the G Plus buttom reders itself?

user2203937
  • 81
  • 1
  • 8

4 Answers4

1

The 'immediate' parameter did it for me, although it has the same affect as 'approvalprompt', prompts for consent. Facebook seems to handle these options a little better.

gapi.signin.render("splashGPlusReg", { 
'callback': GPSignInCallback, 
'clientid': '<yourclientId>', 
'cookiepolicy': 'single_host_origin',
'immediate': false, 
'requestvisibleactions': 'http://schemas.google.com/AddActivity',
'scope': '<scopes>'                           
});
  • 1
    'immediate' did not work, 'approvalprompt' works, but asks for the user to login again. I'd like to have the option to just start doing something after the user clicks the button. Something so simple, and yet i'm unable to do it – carlosvini Jun 09 '14 at 15:34
  • @carlosvini Did you ever find a solution to this ridiculous problem? – j_d Mar 16 '16 at 13:17
  • @JohnDoe Actually I did. But I'm using "gapi.auth.signIn" instead of "gapi.signin.render", I don't remember why and I'm afraid i can't search it right now. Here's the code: https://gist.github.com/jp7carlos/36572ba03bc7f01e5b59 – carlosvini Mar 16 '16 at 14:40
  • Thanks for that. I think most of the trouble here comes from using Google's drop-in UI which is meant to be helpful but really isn't. Cheers. – j_d Mar 16 '16 at 15:04
1

You have two ways to Remove immediate Google Plus Login.

1- not a good approach: use data-approvalprompt="force" in your button. I wrote an example below:

    <span id="signinButton" >
       <span
        class="g-signin g-link"
        data-callback="signinCallback"
        data-clientid="*****.apps.googleusercontent.com"
        data-cookiepolicy="single_host_origin"
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read"    
        data-approvalprompt="force"
        style= "cursor:pointer;">
        Login With Google
      </span>
    </span>

It is not a good approach because if you add this, then Google ask a user to give one extra permission for offline access. So it may let user won't signup at all because of this permission.

2- better approach: just signout from Google after receiving response in your signincallback function. just add:

gapi.auth.signOut();

You should write this line after you received the response. It is better to keep it as a last line inside the request.execute(function(resp) function.

By adding this code, Google won't render the login unless someone click on the login button.This approach is recommended by Google too.

Iman Sedighi
  • 6,808
  • 4
  • 47
  • 53
0

I found a way to do this, maybe it's exactly what you want too:

disable automatic authentication for Google+ social sign-in

Community
  • 1
  • 1
Alexandre Martini
  • 319
  • 1
  • 3
  • 13
0

It's not the cleanest fix, but you can try filtering on the status.method property of the authResult passed into the callback.

Filter any callbacks that are triggered with authResult.status.method set to AUTO, but process any that are null (logged in via single authorized Google account) or PROMPT (user chose one of several Google accounts).

Will
  • 1