Reputation: 351
I followed the instructions in:
https://developers.google.com/identity/sign-in/web/sign-in
Everything works (signing in a user) but I cannot sign out a user. I get the following error :
Uncaught gapi.auth2.ExternallyVisibleError: gapi.auth2 has been initialized with different options
It fails when executing :
auth2 = gapi.auth2.init();
(https://developers.google.com/identity/sign-in/web/sign-in#sign_out_a_user)
I need code examples to sign out the user from my web application and also to sign the user completely from the Google account.
Upvotes: 4
Views: 6040
Reputation: 193
I encountered the same problem.
If you set it up according to these instructions you can sign out a user by calling
gapi.auth.signOut();
Upvotes: 1
Reputation: 652
You should run this code from web server (ex: Apache, Node.js). The Google Sign In API not working if you directly access files (ex: index.html)
Upvotes: 0
Reputation: 4995
gapi.auth2.init(); was called before by
<div class="g-signin2">
which uses gapi.auth2. You should call
auth2 = gapi.auth2.getAuthInstance();
instead of gapi.auth2.init(). Full example:
<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>
Upvotes: 5