1

I am trying to implement Google+ sign in for web sites.

My desired flow is:

  1. User lands on login page
  2. Clicks Google Sign In button
  3. I receive email and processing it on server side

The problem is, whatever script I try, Google always invoking and UNWANTED auto sign in. I want it to be initiated only when user clicks the button and prevent auto triggering google events.

Taylan Aydinli
  • 4,247
  • 15
  • 38
  • 32
eddyuk
  • 3,900
  • 5
  • 34
  • 56
  • "I receive email and processing it on server side" what does this mean? And what does 'auto sign in' mean? What do you mean by 'auto'? – Taylan Aydinli Feb 18 '15 at 08:37
  • There is a code sample provided by google+ platform, how to retrieve email of user. I send this email to MY server in order to create user account. By auto - I mean when user lands on page where google+ sign in button located - google script attempts to sign in this user automatically without him pressing the button – eddyuk Feb 18 '15 at 08:40
  • Which code sample are you using? Can you post the link here? – Taylan Aydinli Feb 18 '15 at 08:42
  • https://developers.google.com/+/web/people/ – eddyuk Feb 18 '15 at 08:50

1 Answers1

2

The 'auto sign in' thing you mention is how the Google+ Sign In method functions by default. If you want full control of the sign in process, you need to use the Google Plus API and manually go through the whole OAuth process. I don't know what platform you're developing on but there are plenty of client libraries for the Google+ API.

If you insist on using the Google+ JavaScript library, here's one option: The Google Plus Sign In button has a data-callback attribute. An object is passed into this callback function. That object has a status property which you can use to check whether the sign-in was made 'automatically' as you mention, or was made after the user clicked the sign-in button.

function google_plus_signin_callback(authResult){
    if(authResult.status.method == 'AUTO'){
        // handle auto sign-in scenario
    }else if(authResult.status.method == 'PROMPT') {
        // handle user initiated sign-in scenario
    }
}

So if the user was signed in automatically, you can use the sign out method to sign her out or you can try doing something else depending on how you want your application to behave.

Taylan Aydinli
  • 4,247
  • 15
  • 38
  • 32