title: Refresh page on new user sign in when using Google oAuth 2.0
body: <p>I'm trying to make a website using <a href="https://developers.google.com/identity/sign-in/web/devconsole-project" rel="noreferrer">Google Sign For Websites.</a> Mostly just for the sake of learning about how it works.</p>
  
  <p>I've followed the steps outlined in that tutorial Google Provides which works fine. Users can successfully sign into my site, it is able to pass the users ID to the backend and then verify the ID server side using a php script.</p>
  
  <p>Php then creates a session for the user on the website. What I can't figure out is how would I refresh the page when a user clicks the Google Sign in button and the sign in is successful. Refreshing the page would allow the home page to be reloaded with the new php session data.</p>
  
  <pre><code>&lt;div class="g-signin2 signin-button" data-onsuccess="onSignIn" data-theme="dark"&gt;&lt;/div&gt;
  
  function onSignIn(googleUser){
  
          // The ID token you need to pass to your backend:
          var id_token = googleUser.getAuthResponse().id_token;
  
          var xhr = new XMLHttpRequest();
          xhr.open('POST', 'https://mywebsite.com/tokensignin.php');
          xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          xhr.onload = function() {
              console.log('Signed in as: ' + xhr.responseText);
          };
          xhr.send('idtoken=' + id_token);
        };
  </code></pre>
  
  <p>I've tried using simply <code>location.reload()</code> inside of the onload = function() portion of the code. This causes the page to just infinately refresh every time it is loaded however since Google verifys that the user is signed in through this <code>xhr</code> variable every time.</p>
  
  <p>I've tried <a href="https://developers.google.com/identity/sign-in/web/reference#googleauthissignedinlistenlistener" rel="noreferrer">looking through their reference</a> to use <code>GoogleAuth.isSignedIn.listen(listener)</code> to monitor any changes but it doesn't seem to fullfull what I want it to or I'm not using it correctly since I don't exactly know what the listener should be.</p>
  
  <p>The other option might be to use their <code>GoogleAuth.attachClickHandler(container, options, onsuccess, onfailure)</code> function but I'm not entirely sure how the properly configure the options field/variable.</p>
  
  <p>If someone could provide some insight as to how this world work I would greatly appreciate it.</p>
  
  <p>To summarize if the user is already signed into my website using Google I want the page to do nothing, if they click the signin button, after the sign in is successful I want to refresh the page they are on.</p>