I get error:
Uncaught TypeError: Cannot read property 'signOut' of undefined
On this line: auth2.signOut()
I do NOT have the google signin button on the page below. I also tried executing function signOutGoogle
, but that too results in an error.
Top of page my page in <head>
:
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="MYAPPIDPLACEHOLDERWHICHIFILLEDOUT.apps.googleusercontent.com">
Before </body>
tag I have:
<script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
JavaScript code:
function onLoad() {
console.error('onLoad executed.');
var auth2;
gapi.load('auth2', function () {
auth2 = gapi.auth2.init({
client_id: 'MYAPPIDPLACEHOLDERWHICHIFILLEDOUT.apps.googleusercontent.com'
});
auth2 = gapi.auth2.getAuthInstance();
});
//check if url contains ?signout=true
var url = window.location.href;
if (url.toString().indexOf('?signout=true') != -1) {
console.error('param found');
auth2.signOut().then(function () {
console.error('User signed out');
});
}
}
UPDATE 1
For some reason ga
is called (which I don't do explicitly myself) and failing, what's happening here?
I already checked here:
- TypeError: gapi.auth2 undefined
- gapi is not defined - Google sign in issue with gapi.auth2.init
- HTML PHP google single sign on signout will throw "Cannot read property 'getAuthInstance' of undefined"
- How to check if user is logged in or not with "Google Sign In" (OAuth 2.0)
UPDATE 2
Now I'm getting error
Uncaught Error: ia
from `Uncaught TypeError: Cannot read property 'signOut' of undefined`
No comments:
Post a Comment