title: HTML PHP google single sign on signout will throw "Cannot read property 'getAuthInstance' of undefined"
body: <p>I have created google single sign on by following steps mentioned in 
  <a href="https://developers.google.com/identity/sign-in/web/sign-in" rel="noreferrer">https://developers.google.com/identity/sign-in/web/sign-in</a> </p>
  
  <p>The sign in works like a charm but when i try to integrate sign out as per the article in the link</p>
  
  <p>i get the following javascript error in console</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'getAuthInstance' of
    undefined</p>
  </blockquote>
  
  <p>And my signout function looks like</p>
  
  <pre><code>&lt;script&gt;
      function signOut() {
         var auth2 = gapi.auth2.getAuthInstance();
         auth2.signOut().then(function () {
            console.log('User signed out.');
         });
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>and my sign in looks like </p>
  
  <pre><code>function onSignIn(googleUser) {
  
      var profile = googleUser.getBasicProfile();
      console.log('ID: ' + profile.getId()); 
      console.log('Name: ' + profile.getName());
      console.log('Image URL: ' + profile.getImageUrl());
      console.log('Email: ' + profile.getEmail());
  
  }
  </code></pre>