Quit Google API not working

I followed the instructions below:

https://developers.google.com/identity/sign-in/web/sign-in

Everything works (signed by the user), but I can not write the user out. I get the following error:

Unprepared gapi.auth2.ExternallyVisibleError: gapi.auth2 was initialized with various options

Execution Failure:

auth2 = gapi.auth2.init();

( https://developers.google.com/identity/sign-in/web/sign-in#sign_out_a_user )

I need code examples to log a user out of my web application, and also fully sign a user from a Google account.

+4
source share
3 answers

gapi.auth2.init (); was called before

<div class="g-signin2">

gapi.auth2.

auth2 = gapi.auth2.getAuthInstance();

gapi.auth2.init(). :

<a href="#" onclick="signOut();">Sign out</a>
<script>
  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');
    });
  }
</script>
+5
0

You must run this code from a web server (for example: Apache, Node.js). The Google login API does not work if you access files directly (for example: index.html)

0
source

All Articles