Friday 23 July 2021

`Uncaught TypeError: Cannot read property 'signOut' of undefined`

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

enter image description here

For some reason ga is called (which I don't do explicitly myself) and failing, what's happening here?

I already checked here:

UPDATE 2

Now I'm getting error

Uncaught Error: ia

enter image description here



from `Uncaught TypeError: Cannot read property 'signOut' of undefined`

No comments:

Post a Comment