Problem logout with Google social login

1

I'm having trouble logging out with Google social login. I was able to set the login and execute successfully receiving the return of the name, email and photo, and redirected to the dashboard successfully.

In the dashboard I entered the settings meta, plataform.js and the link to leave 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');
    });
}
    
asked by anonymous 05.06.2018 / 21:12

1 answer

0

You will need to reload and start the lib gapi.auth2 on the dashboard page. Example (replace SEU_ID_DE_CLIENTE with its current id ):

<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>
    
05.06.2018 / 23:46