I am using Google Auth Login
for my application. My SignIn
button is on the login page and my logout is a part of my header which is included throughout my application. On clicking on logout button I am not being able to sign the user out of my application
Login.tpl code (Which contains sign in button)
<div align="middle" class="g-signin2" data-onsuccess="onSignIn"></div>
<meta name="google-signin-client_id" content="CLIENT_ID">
I am able to login but not being able to logout.Logout button is a part of the header.tpl which is included in all the files but I am getting the error marked in bold above.
Header.tpl code
<meta name="google-signin-client_id" content="CLIENT_ID">
<a href="/users/auth/login" class = "logout"><i class="fa fa-sign-out pull-right"></i> Log Out</a>
My JS code
$(".logout").click(function(event) {
event.preventDefault();
gapi.load('auth2', function () {
var auth2 = gapi.auth2.init({
client_id: 'CLIENT_ID',
cookiepolicy: 'single_host_origin'
});
auth2.then(function(){
// this get called right after token manager is started
auth2.signOut();
console.log('User signed out.');
});
});
window.location = $(this).attr('href');
});
The code is never entering the block in which signout is defined and hence I am not getting anything in the console as well.
However if I run this code in console, the user gets logged out successfully but this isn't working on the application when I am running it on localhost
Any leads would be highly appreciated.