title: How to check if user is logged in or not with "Google Sign In" (OAuth 2.0)
body: <p>I am implementing Google log in for the first time as described <a href="https://developers.google.com/identity/sign-in/web/devconsole-project">here</a> and <a href="https://developers.google.com/identity/sign-in/web/sign-in">here</a>.</p>
  
  <p>I am using HTML with Javascript.</p>
  
  <p>The problem that needs solving is as follows: How can I, after the initial login, on a different page (say a landing page, or portal that the user sees after logging in), check if the user is logged in?  Is there a service I can call to check the user's login in status with my app key or something similar?
  I assume I would have to include the google API on each page.</p>
  
  <p>Login Page Code:</p>
  
  <p>Script In Head (Code from Google's tutorial listed above):</p>
  
  <pre><code>&lt;head&gt;
  ....
  &lt;script src="https://apis.google.com/js/platform.js" async defer&gt;&lt;/script&gt;
  
  &lt;script&gt;
  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());
  
    alert(profile.getName());   
  }
  
  function logout()
  {
      alert('logging out');
      var auth2 = gapi.auth2.getAuthInstance();
          auth2.signOut().then(function () {
          console.log('User signed out.');
          });
  }
  ...
  &lt;/head&gt; 
  </code></pre>
  
  <p>Code In Body (1st line from Google's tutorial listed above, 2nd line to trigger logout test)</p>
  
  <pre><code>&lt;body&gt;
  ...
  &lt;div class="g-signin2" data-onsuccess="onSignIn"&gt;&lt;/div&gt;
  &lt;div onmousedown="logout()"&gt;Logout&lt;/div&gt;
  ...
  &lt;/body&gt;
  </code></pre>
  
  <p>Is there some way I can include the google API on another page, and then call some check login status function? Or another way to concretely tell if the user is logged in or out?</p>