Google+ Sign-In with JavaScript callback issue
callback, google-api, google-oauth, google-plus, javascript
Solution
I'm facing this same issue here, but I'm calling gapi.auth.signIn() via a button click handler. The callback is still called twice. One thing I noticed between the two authResult objects was that authResult.status.method is 'AUTO' in the first call (before the popup window appears) and is 'PROMPT' in the second call after the window is auto-dismissed due to previous authorisation.
The solution I'm exploring now is to ignore the AUTO instance and only process the PROMPT instance of the callback. Not sure how this will work once I revoke the permissions within Google due to the lack of details in the docs on the 'status' object.
Problem
I am working on a function which allows users to sign in on my website with their Google account. My code is based on the Google documentation (others signIn() options are in meta tags). ``` function login() { gapi.auth.signIn({'callback': function (authResult) { if (authResult['status']['signed_in']) { console.log('Okay'); }else { console.log('Error'); } } }); } ``` When I call login(), a Google pop up appears, I approve the terms of my application and everything works fine. But the callback is called twice : - 1st case: If I never approved apps permissions then the callback will be call at the opening of the pop up AND when I will approve the permissions. So it will write "Error" and "Okay". - 2nd case: If I already approved the permissions, it will write "Okay" two times. I added the option `'approvalprompt': 'force'` to the signIn() function. The callback function is no longer called twice but it forces the user to approve the app's permissions, even if previously approved. So it's not user friendly. Is there a friendly user way to approve the app's permissions one time without having two callback ? Thank you.