Problem logout with Google social login

Asked

Viewed 45 times

1

I’m having trouble running logout with Google social login. I managed to set the login and run successfully receiving the return of the name, email and photo, and redirect to Dashboard successfully.

On Dashboard I entered the meta settings, Plataform.js and link to exit the page, and I get the following message,

Typeerror: gapi.auth2 is Undefined

<a onclick="signOut();"> sair</a>

function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
        auth2.signOut().then(function () {
            alert('OK');
    });
}

1 answer

0


You will need to reload and start the lib gapi.auth2 on the Dashboard tab. Example (replace SEU_ID_DE_CLIENTE for his id current):

<html>
<head>
   <meta name="google-signin-client_id" content="SEU_ID_DE_CLIENTE">
</head>
<body>
  <script>
    function signOut() {
      var auth2 = gapi.auth2.getAuthInstance();
      auth2.signOut().then(function () {
         alert('OK');
      });
    }

    function onLoad() {
      gapi.load('auth2', function() {
        gapi.auth2.init();
      });
    }
  </script>
  <a onclick="signOut();"> sair</a>

  <script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
</body>
</html>
  • Solved dvd.. thanks a lot!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.