title: How do I initialise Google Sign in with no login button?
body: <p>The below code works as a simple test page that uses <a href="https://developers.google.com/identity/sign-in/web/" rel="noreferrer">Google sign in</a>:</p>
  
  <pre><code>&lt;html lang="en"&gt;
    &lt;head&gt;
  
      &lt;script type="text/javascript"&gt;
  
          function onGapiLoaded() {
              auth = gapi.auth2.init({
                  client_id: "REPLACE_WITH_YOUR_ID",
                  scope: "profile email"
  
              });
  
              console.log( "signed in: " + auth.isSignedIn.get() );
  
              auth.isSignedIn.listen( function(signedIn){ console.log( "signedin: " + signedIn ) } );
  
              gapi.signin2.render( "signInButton", {
                  'width': 230,
                  'height': 50,
                  'longtitle': true,
                  'theme': 'dark',
                  'onsuccess': onSignIn
              } );
          }
  
            function onSignIn(googleUser) {
              // Useful data for your client-side scripts:
              var profile = googleUser.getBasicProfile();
              console.log("Name: " + profile.getName());
            };
  
  
      &lt;/script&gt;
  
      &lt;script src="https://apis.google.com/js/platform.js?onload=onGapiLoaded" async defer&gt;&lt;/script&gt;
  
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="signInButton" class="g-signin2"&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However if I remove the <code>class="g-signin2"</code> from the signin button, or remove the button completely not only does the button disappear but the whole sign in library stops working - I get an uncaught exception:</p>
  
  <blockquote>
    <p>Cannot read property 'init' of undefined</p>
  </blockquote>
  
  <p>when I try to call <code>gapi.auth2.init</code> and the user is not logged in. It seems that the auth library relies on a button being present in the dom to initialise.</p>
  
  <p>I am planning to incorporate this in my Angular app that will initialise the auth lib in a service before any button appears on the stage. If the user is logged in already no login button will appear.
  Based on the behaviour here I will not be able to use this lib without having a button in the DOM which seems rather constricting.</p>