I have a problem when I developed my website with Google+ sign-in: I did step by step that the doc told me but I always failed at step4: https://developers.google.com/+/web/
Change this setting "immediate: true", to be false " immediate: false". But if you like to make more complex implementation look at the first sample here https://developers.google.com/api-client-library/javascript/start/start-js. You have to calls to Google's "gapi.auth.authorize({...", the first one with "immediate: true", and the second one with "immediate: false".