G+ Login Immediately Logs Me out 3x Using g-signin

2019-04-24 14:22发布

问题:

My code in HEAD is:

<meta name="google-signin-clientid" content="XXXXXXX.apps.googleusercontent.com" />
<meta name="google-signin-cookiepolicy" content="single_host_origin" />
<meta name="google-signin-approvalprompt" content="auto" />
<meta name="google-signin-callback" content="signinCallback" />
<meta name="google-signin-scope" content="https://www.googleapis.com/auth/games" />

Here is my button code:

<span id="signinButton"><span class="g-signin"></span></span>

Here is the JavaScript:

function signinCallback(authResult) {
    if (authResult['status']['signed_in']) {
        console.log('Signed In');
    } else {
        console.log('Sign-in state: ' + authResult['error']);
    }
}
(function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/client:plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();

When I click the signin button, a dialog opens and authenticates me, then the following is printed to the console:

  • Sign-in state: Signed In, Wed May 21 2014 17:31:05 GMT-0700 (PDT)
  • Sign-in state: user_signed_out, Wed May 21 2014 17:31:06 GMT-0700 (PDT)
  • Sign-in state: user_signed_out, Wed May 21 2014 17:31:06 GMT-0700 (PDT)
  • Sign-in state: user_signed_out, Wed May 21 2014 17:31:08 GMT-0700 (PDT)

I have no code on my page that calls sign out, yet it is called repeatedly. The first two sign outs happen at the same time and the last one happens about 2 seconds later. I can't find anything in the documents that would explain this behavior. Any ideas?

回答1:

Had similar issue, solved it by revoking access for my app in my google account so that I had to re-grant access to production app when I had previously granted my dev env access.